Save instrument objects and variables to MAT-file
save filename obj1 obj2 ...
The MAT-file name.
Instrument objects or arrays of instrument objects.
save filename saves all MATLAB® variables to the MAT-file
filename. If an extension
is not specified for
filename, then a .
extension is used.
save filename obj1 obj2 ... saves the
obj1 obj2 ... to the MAT-file
This example illustrates how to use the command form and the functional form of
s = serial('COM1'); set(s,'BaudRate',2400,'StopBits',1) save MySerial1 s set(s,'BytesAvailableFcn',@mycallback) save('MySerial2','s')
You can use
save in the functional form as well as the command
form shown above. When using the functional form, you must specify the filename and
instrument objects as character vectors. For example, on a Windows® machine, save the serial port object
s to the file
s = serial('COM1'); save('MySerial','s')
Any data that is associated with the instrument object is not automatically stored
in the MAT-file. For example, suppose there is data in the input buffer for
obj. To save that data to a MAT-file, you must bring the data
into the MATLAB workspace using one of the synchronous read functions, and then save
the data to the MAT-file using a separate variable name. You can also save data to a
text file with the
You return objects and variables to the MATLAB workspace with the
load command. Values for
read-only properties are restored to their default values upon loading. For example,
Status property is restored to
To determine if a property is read-only, examine its reference pages or use the