Справочник Пользователя для Rigol MSO1074Z-S 4-channel oscilloscope, Digital Storage oscilloscope, MSO1074Z-S

Модели
MSO1074Z-S
Скачать
Страница из 172
RIGOL 
DS1000Z Programming Guide 
3-7
 
 
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 E:\DS1000Z_Demo.   
 
 
2.  Click File  New  Blank M-File in the Matlab interface to create an empty M file.   
 
3.  Add the following codes in the M file: 
 
% Create VISA object
 
DS1000z = visa('ni','USB0::0x1AB1::0x04CE::DS1T00000006::INSTR');   
 
% Set the device property. In this demo, the length of the input buffer is set to 2048.
 
DS1000z.InputBufferSize = 2048; 
 
% Open the VISA object created
 
fopen(DS1000z);
   
 
% Read the waveform data
 
fprintf(DS1000z, ':wav:data?' );
   
 
% Request the data
 
[data,len]= fread(DS1000z,2048);
   
 
% Close the VISA object
 
fclose(DS1000z);
   
delete(DS1000z); 
clear DS1000z; 
 
% Data processing. The waveform data read contains 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, then 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);
 
 
wave = wave'; 
subplot(211); 
plot(wave); 
fftSpec = fft(wave',2048); 
fftRms = abs(fftSpec'); 
fftLg = 20*log(fftRms); 
subplot(212); 
plot(fftLg);   
 
4.  Save the M file under the current directory. In this demo, the M file is named as 
DS1000Z_Demo_MATLAB.m.