load (serial)

Load serial port objects and variables into MATLAB workspace


load filename
load filename obj1 obj2...


load filename returns all variables from the file specified by filename into the MATLAB® workspace.

load filename obj1 obj2... returns the serial port objects specified by obj1 obj2 ... from the file filename into the MATLAB workspace.

out = load('filename','obj1','obj2',...) returns the specified serial port objects from the 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.


    Note:   This example is based on a Windows® platform.

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');

Save s1 and s2 to the file MyObject.mat, and then load the objects back into the workspace:

save MyObject s1 s2;
load MyObject s1;
load MyObject s2;

get(s1, {'Parity', 'DataBits'})
ans = 
    'mark'    [7]
get(s2, {'Parity', 'DataBits'})
ans = 
    'none'    [8]

More About

expand all


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.

See Also


Was this topic helpful?