Instrument Control Toolbox | ![]() ![]() |
Convert instrument object to MATLAB code
Syntax
obj2mfile(obj,'filename') obj2mfile(obj,'filename','syntax
') obj2mfile(obj,'filename','mode
') obj2mfile(obj,'filename','syntax'
,'mode
')
Arguments
Description
obj2mfile
converts (obj,'filename')
obj
to the equivalent MATLAB code using the set
syntax and saves the code to filename
. Only those properties not set to their default value are saved.
obj2mfile
converts (obj,'filename','
syntax')
obj
to the equivalent MATLAB code using the syntax specified by syntax
. You can specify syntax
to be set
or dot
. set
uses the set syntax, while dot
uses the dot notation.
obj2mfile
converts the properties specified by (obj,'filename','
mode
')
mode
. You can specify mode
to be all
or modified
. If mode
is all
, then all properties are converted to code. If mode
is modified
, then only those properties not set to their default value are converted to code.
obj2mfile
converts the specified properties to code using the specified syntax.(obj,'filename','
syntax
','
mode
')
Remarks
You can recreate a saved instrument object by typing the name of the M-file at the MATLAB command line.
If the UserData
property is not empty or if any of the callback properties are set to a cell array of values or a function handle, then the data stored in those properties is written to a MAT-file when the instrument object is converted and saved. The MAT-file has the same name as the M-file containing the instrument object code (see the example below).
Read-only properties are restored with their default values. For example, suppose an instrument object is saved with a Status
property value of open
. When the object is recreated, Status
is set to its default value of closed
.
Example
Suppose you create the GPIB object g
, and configure several property values.
g = gpib('ni',0,1); set(g,'Tag','MyGPIB object','EOSMode','read','EOSCharCode','CR') set(g,'UserData',{'test',2,magic(10)})
The following command writes MATLAB code to the files MyGPIB.m
and MyGPIB.mat
.
MyGPIB.m
contains code that recreates the commands shown above using the dot notation for all properties that have their default values changed. Because UserData
is set to a cell array of values, this property appears in MyGPIB.m
as
To recreate g
in the MATLAB workspace using a new variable, gnew
:
The associated MAT-file, MyGPIB.mat
, is automatically run and UserData
is assigned the appropriate values.
Functions
![]() | memwrite | propinfo | ![]() |