|MATLAB Function Reference|
User-defined extension of
load function for user objects
b = loadobj(a)
load function for user objects. When an object is loaded from a MAT-file, the
load function calls the
loadobj method for the object's class if it is defined. The
loadobj method must have the calling sequence shown; the input argument
a is the object as loaded from the MAT-file, and the output argument
b is the object that the
load function will load into the workspace.
These steps describe how an object is loaded from a MAT-file into the workspace:
loadfunction detects the object
ain the MAT-file.
loadfunction looks in the current workspace for an object of the same class as the object
a. If there isn't an object of the same class in the workspace,
loadcalls the default constructor, registering an object of that class in the workspace. The default constructor is the constructor function called with no input arguments.
loadfunction checks to see if the structure of the object
amatches the structure of the object registered in the workspace. If the objects match,
ais loaded. If the objects don't match,
ato a structure variable.
loadfunction calls the
loadobjmethod for the object's class if it is defined.
loadpasses the object
loadobjmethod as an input argument. Note that the format of the object
ais dependent on the results of step 3 (object or structure). The output argument of
b, is loaded into the workspace in place of the object
loadobj can be overloaded only for user objects.
load will not call
loadobj for built-in data types (such as
loadobj is invoked separately for each object in the MAT-file. The
load function recursively descends cell arrays and structures, applying the
loadobj method to each object encountered.
A child object does not inherit the
loadobj method of its parent class. To implement
loadobj for any class, including a class that inherits from a parent, you must define a
loadobj method within that class directory.
© 1994-2005 The MathWorks, Inc.