MATLAB Function Reference | ![]() ![]() |
Load serial port objects and variables into the MATLAB workspace
Syntax
load filename load filename obj1 obj2... out = load('filename','obj1','obj2',...)
Arguments
filename |
The MAT-file name. |
obj1 obj2... |
Serial port objects or arrays of serial port objects. |
out |
A structure containing the specified serial port objects. |
Description
load filename
returns all variables from the MAT-file specified by filename
into the MATLAB workspace.
load filename obj1 obj2...
returns the serial port objects specified by obj1
obj2
... from the MAT-file filename
into the MATLAB workspace.
out = load('filename','obj1','obj2',
...)
returns the specified serial port objects from the MAT-file filename
as a structure to out
instead of directly loading them into the workspace. The field names in out
match the names of the loaded serial port objects.
Remarks
Values for read-only properties are restored to their default values upon loading. For example, the Status
property is restored to closed
. To determine if a property is read-only, examine its reference pages.
If you use the help
command to display help for load
, then you need to supply the pathname shown below.
help serial/private/load
Example
Suppose you create the serial port objects s1
and s2
, configure a few properties for s1
, and connect both objects to their instruments.
s1 = serial('COM1'); s2 = serial('COM2'); set(s1,'Parity','mark','DataBits',7) fopen(s1) fopen(s2)
Save s1
and s2
to the file MyObject.mat
, and then load the objects into the workspace using new variables.
save MyObject s1 s2 news1 = load MyObject s1 news2 = load('MyObject','s2')
Values for read-only properties are restored to their default values upon loading, while all other properties values are honored.
get(news1,{'Parity','DataBits','Status'}) ans = 'mark' [7] 'closed' get(news2,{'Parity','DataBits','Status'}) ans = 'none' [8] 'closed'
Functions
Properties
![]() | loadobj | log | ![]() |