Data Acquisition Toolbox
  Function/Property:
    Search    Help Desk 
obj2code    Examples

Convert device object, channels, or lines to MATLAB code and save to disk.

Syntax

obj2code(obj, 'file');

obj2code(obj, 'file', syntax);

obj2code(obj, 'file', 'all');

obj2code(obj, 'file', syntax, 'all');

Arguments

obj
An existing device object
file
The file that the MATLAB code is written to. The full pathname of file can be specified. If an extension is not specified for file, the .m extension is used.
syntax
(optional)
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'
(optional)
If 'all' is not specified, only properties that are not set to their default values are written to file. If 'all' is specified, all properties are written to file.

Description

obj2code(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.

obj2code(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.

obj2code(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, 'named' uses named referencing (if defined).

obj2code(obj, 'file', syntax, 'all') 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, and 'named' uses named referencing (if defined). 'all' specifies that all properties are written to file.

Note:
If UserData is not empty or if any of the action properties are set to a cell array of values, then the data stored in those properties is written to a MAT-file 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).

Example

Suppose you 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 which recreates the analog input code shown above using subscripted assignment for all properties that have their default values changed. Since StartAction is set to a cell array of values, this property appears in myai.m as

and is saved in myai.mat as

To load ai and assign the device object to a new variable ai_new

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



[ Previous | Help Desk | Next ]