3 Programming Demos RIGOL
DS2000E Programming Guide
MATLAB Programming Demo
The program used in this demo: MATLAB R2009a
The function realized in this demo: make FFT operation on the waveform data and draw the
waveform.
1. Run the MATLAB software and modify the current directory (namely modify the Current Directory
at the top of the software). In this demo, the current directory is modified to
D:\DS2000E_Demo\MATLAB.
2. Click File ïƒ New ïƒ Blank M-File in the MATLAB interface to create an empty M file. Add the
following codes in the M file:
% Create VISA object . 'ni' is the saler Parameter and can be agilent, NI or tek.
'USB0::0x1AB1::0x04B0::DS2A0000000000::INSTR' is the device resource descriptor. You need to
set the device property. In this demo, set the length of the input buffer to 2048
DS2000E = visa( 'ni','USB0::0x1AB1::0x04B0::DS2A0000000000::INSTR' );
DS2000E.InputBufferSize = 2048;
% Open the VISA object created
fopen(DS2000E);
% Read waveform
fprintf(DS2000E, ':wav:data?' );
% Request data
[data,len]= fread(DS2000E,2048);
% Turn off the device
fclose(DS2000E);
delete(DS2000E);
clear DS2000E;
% Data processing. The waveform data read contains the TMC header. The length of the header is 11
bytes; wherein, the first 2 bytes are the TMC header denoter (#) and the width descriptor (9)
respectively, the 9 bytes following are the length of the data which is followed by the waveform data
and the last byte is the terminator (0x0A). Therefore, the effective waveform points read is from the
12nd to the next to last.
wave = data(12:len-1);