Instrument Control Toolbox | ![]() ![]() |
Example: Reading Binary Data
This example illustrates how you can download the TDS 210 oscilloscope screen display to MATLAB. The screen display data is transferred to MATLAB and saved to disk using the Windows bitmap format. This data provides a permanent record of your work, and is an easy way to document important signal and scope parameters.
g
associated with a National Instruments GPIB controller with board index 0, and an instrument with primary address 1.
g
to the oscilloscope.
Wait until the read operation completes, and then transfer the data to the MATLAB workspace as unsigned 8-bit integers.
g
, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.
Viewing the Bitmap Data
To view the bitmap data, you should follow these steps:
imread
function.
imagesc
function.
Note that the MATLAB file I/O versions of the fopen
, fwrite
, and fclose
functions are used.
fid = fopen('test1.bmp','w'); fwrite(fid,out,'uint8'); fclose(fid) a = imread('test1.bmp','bmp'); imagesc(fliplr(a'))
Because the scope returns the screen display data using only two colors, an appropriate colormap is selected.
The resulting bitmap image is shown below.
![]() | Example: Writing and Reading Text Data | Example: Parsing Input Data Using scanstr | ![]() |