Instrument Control Toolbox    

Saving and Loading Instrument Objects

You can save an instrument object to disk using two possible formats:

You can also save data transferred between the object and the instrument using these two functions. However, it is easier to use the record function for this purpose as described in Debugging: Recording Information to Disk.

Saving Instrument Objects to an M-File

You can save an instrument object to an M-file using the obj2mfile function. obj2mfile provides you with these options:

For example, suppose you create the GPIB object g, return instrument identification information to the variable out, and store out in the UserData property.

The following command saves g and the modified property values to the M-file mygpib.m. Because the UserData property is not empty, its value is automatically written to the MAT-file mygpib.mat.

Use the type command to display mygpib.m at the command line.

Loading the Instrument Object

To load an instrument object that was saved as an M-file into the MATLAB workspace, type the name of the M-file at the command line. For example, to load g from the M-file mygpib.m:

The display summary for g is shown below. Note that the read-only properties such as Status, BytesAvailable, ValuesReceived, and ValuesSent are restored to their default values.

When loading g into the workspace, the MAT-file mygpib.mat is automatically loaded and the UserData property value is restored.


  Saving and Loading the Session Saving Objects to a MAT-File