Data Acquisition Toolbox    
obj2mfile

Convert device objects, channels, or lines to MATLAB code

Syntax

Arguments

obj
A device object, array of device objects, channels, or lines.
'file'
The file that the MATLAB code is written to. The full pathname can be specified. If an extension is not specified, the .m extension is used.
'syntax'
Syntax of the converted MATLAB code. By default, the set syntax is used. If dot is specified, then the subscripted referencing syntax is used. If named is specified, then named referencing is used (if defined).
'all'
If all is specified, all properties are written to file. If all is not specified, only properties that are not set to their default values are written to file.

Description

obj2mfile(obj,'file') converts obj to the equivalent MATLAB code using the set syntax and saves the code to file. By default, only those properties that are not set to their default values are written to file.

obj2mfile(obj,'file','syntax') converts obj to the equivalent MATLAB code using syntax and saves the code to file. The values for syntax can be set, dot, or named. set uses the set syntax, dot uses subscripted assignment (dot notation), and named uses named referencing (if defined).

obj2mfile(obj,'file','all') converts obj to the equivalent MATLAB code using the set syntax and saves the code to file. all specifies that all properties are written to file.

obj2mfile(obj,'file','syntax','all') converts obj including all of obj's properties to the equivalent MATLAB code using syntax and saves the code to file.

Remarks

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 when the object is converted and saved. The MAT-file has the same name as the M-file containing the object code (see the example below).

You can recreate the saved device objects by typing the name of the M-file at the command line. You can also recreate channels or lines, by typing the name of the M-file with a device object as the only input.

Example

Create the analog input object ai for a sound card, add two channels, and set values for several properties.

The following command writes MATLAB code to the files myai.m and myai.mat.

myai.m contains code that recreates the analog input code shown above using the dot notation for all properties that have their default values changed. Because StartFcn is set to a cell array of values, this property appears in myai.m as

and is saved in myai.mat as

To recreate ai and assign the device object to a new variable ainew:

The associated MAT-file, myai.mat, is automatically loaded.


  muxchanidx peekdata