Saving Your Test

Saving the Test as MATLAB Code

In the preceding examples of this chapter, you have been saving the test file after creating each step. The test file is saved in XML format. Here are some other save options.

You save the test file as MATLAB® code by clicking the File menu and selecting Save Test as M-Code.

You can execute the test by calling this file from the MATLAB Command Window.

For example, you can save the test file you created in this chapter as tektronix_tds210_ex_test.m. Then you execute the test from the MATLAB Command Window by typing

tektronix_tds210_ex_test

The test results are displayed in the MATLAB Command Window.

Saving the Test as a Driver Function

You save your test as a driver function by clicking the File menu and selecting Save Test as Driver Function.

When you enter a name for the driver test function, the invoke command at the bottom of the dialog box reflects that name. You use that invoke command to execute the driver function from the MATLAB Command Window or in a file.

Creating a Driver Test Function

  1. Click the File menu and select Save Test as Driver Function.

  2. Enter drivertest in the Specify the driver function name field.

  3. Click OK.

A function called drivertest is created and saved as part of the instrument driver file. You can open the driver file in the MATLAB Instrument Driver Editor tool (midedit) to verify that the drivertest function is included.

Calling a Driver Test Function from the MATLAB Command Window

Now that the test function is included in the driver, you access it with the invoke command from MATLAB.

In the MATLAB Command Window,

  1. Create an interface object.

    g = gpib('cec',0,4)
  2. Create a device object, specifying the driver with the drivertest function saved in it.

    obj = icdevice('tektronix_tds210_ex.mdd',g)
  3. Connect to the device.

    connect(obj)
  4. Execute the driver test.

    out = invoke(obj, 'drivertest')
  5. When the test is complete, disconnect from the instrument and delete the objects.

    disconnect(obj)
    delete ([g obj])
Was this topic helpful?