Contact us

Live Chat with Tek representatives. Available 6:00 AM - 4:30 PM

Call

Call us at

Available 6:00 AM – 5:00 PM (PST) Business Days

Download

Download Manuals, Datasheets, Software and more:

DOWNLOAD TYPE
MODEL or KEYWORD

Feedback

How do I get a waveform using the Instrument Control Toolbox in Matlab?

Question :

How do I get a waveform using the Instrument Control Toolbox in Matlab?

Answer :

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)')


This FAQ Applies to:

No product series

Product:

FAQ ID 52581

View all FAQs »