User`s manual

Writing and Reading Data
8-43
fopen(s)
3. Write and read data – Write the *IDN? command to the instrument using
fprintf, and then read back the result of the command using fscanf.
fprintf(s,'*IDN?')
idn = fscanf(s)
idn =
TEKTRONIX,TDS 210,0,CF:91.1CT FV:v1.16 TDS2CM:CMV:v1.04
You need to determine the measurement source. Possible measurement
sources include channel 1 and channel 2 of the oscilloscope.
fprintf(s,'MEASUREMENT:IMMED:SOURCE?')
source = fscanf(s)
source =
CH1
The scope is configured to return a measurement from channel 1. Since the
input signal is connected to channel 2, you must configure the instrument to
return a measurement from this channel.
fprintf(s,'MEASUREMENT:IMMED:SOURCE CH2')
fprintf(s,'MEASUREMENT:IMMED:SOURCE?')
source = fscanf(s)
source =
CH2
You can now configure the scope to return the peak-to-peak voltage, and then
request the value of this measurement.
fprintf(s,'MEASUREMENT:MEAS1:TYPE PK2PK')
fprintf(s,'MEASUREMENT:MEAS1:VALUE?')
Transfer data from the input buffer to MATLAB using fscanf.
ptop = fscanf(s,'%g')
ptop =
2.0199999809E0
4. Disconnect and clean up – When you no longer need s, you should
disconnect it from the instrument, and remove it from memory and from the
MATLAB workspace.
fclose(s)