Frage:
How do I get a waveform using the Instrument Control Toolbox in Matlab?
Antwort:
Here is a simple program to get a waveform and plot it in Matlab. Note this is connecting using GPIB but this could also use serial or ethernet connections:
function ICT_example
%clear all variables
delete(instrfind)
clear all
g = visa('tek','GPIB0::1::INSTR');
fopen(g);
fprintf(g,' DATA :SOURCE CH1')
recordLength=query(g,'HORIZONTAL:RECORDLENGTH?','%s\n','%d');
fclose(g);
g.InputBufferSize = recordLength;
fopen(g);
fprintf(g,' DATA :START 1');
fprintf(g,[' DATA :STOP ' num2str(recordLength)]);
fprintf(g,' DATA :WIDTH 1');
fprintf(g,' DATA : ENC RPB');
fprintf(g,'CURVE?');
data = binblockread(g,'uint8');
ymult = str2num(query(g,'WFMP:YMULT?'));
yoff = str2num(query(g,'WFMP:YOFF?'));
xmult = str2num(query(g,'WFMP:XINCR?'));
xoff = str2num(query(g,'WFMP:PT_OFF?'));
xzero = str2num(query(g,'WFMP:XZERO?'));
ydata = ymult*(data - yoff);
xdata = xmult*((0:length(data)-1)-xoff)+xzero;
%Plot the scaled data.
plot(xdata,ydata)
title('Scaled Waveform Data'); ylabel('Amplitude (V)');
xlabel('Time (s)')
Diese FAQs beziehen sich auf:
Keine Produktreihe
Produkt:
FAQ-ID 52581
Alle FAQs ansehen »