Data Acquisition Toolbox | ![]() ![]() |
Convert device objects, channels, or lines to MATLAB code
Syntax
obj2mfile(obj,'file')
obj2mfile(obj,'file','
syntax
')
obj2mfile(obj,'file','
all
')
obj2mfile(obj,'file','syntax
','all
')
Arguments
Description
converts obj2mfile(obj,'file')
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
.
converts obj2mfile(obj,'file','
syntax
')
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).
converts obj2mfile(obj,'file','
all
')
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
.
converts obj2mfile(obj,'file','
syntax
','
all
')
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.
ai = analoginput('winsound'); addchannel(ai,1:2); set(ai,'Tag','myai','TriggerRepeat',4) set(ai,'StartFcn',{@mycallback,2,magic(10)})
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
To recreate ai
and assign the device object to a new variable ainew
:
The associated MAT-file, myai.mat
, is automatically loaded.
![]() | muxchanidx | peekdata | ![]() |