Matlab programming demo, Matlab programming demo -7 – RIGOL DSG3000 Series User Manual
Page 163

RIGOL
DSG3000 Programming Guide
4-7
Matlab Programming Demo
The program used in this demo: MATLAB R2009a
The functions realized in this demo: read the current frequency and amplitude of the RF signal
generator.
1. Run Matlab and modify the current directory (namely modify the Current Directory at the top of the
software). In this example, the current directory is changed to D:\DSG3000_Demo.
2. Click File New Blank M-File in the Matlab interface to create a blank M file.
3. Add the following codes in the M file.
dsg3000 = visa(
'ni'
,
'USB0::0x1AB1::0x0992::DSG3A1301080006::INSTR'
);
%Create Visa object
fopen( dsg3000 );
%Open the visa object created
fprintf(dsg3000, ':FREQ?' );
%Send request to query the frequency
meas_RF_FREQ = fscanf(dsg3000);
%Read the frequency data
fprintf(dsg3000, ':LEV?' );
%Send request to query the amplitude
meas_RF_LEV = fscanf(dsg3000);
%Read the amplitude data
fclose(dsg3000);
%Close the visa object
display(meas_RF_FREQ);
%Display the frequency read
display(meas_RF_LEV)
%Display the amplitude read
4. Save the M file in the current directory. In this example, the M file is named as
DSG3000_Demo_MATLAB.m.
5. Run the M file and the command window displays the following results.
meas_RF_FREQ =
500000000
meas_RF_LEV =
-140.00
The results above denotes that the current frequency of the RF signal generator is 500 MHz and the
amplitude is -140 dBm.