| MATLAB Function Reference | Search  Help Desk |
| saveobj | See Also |
User-defined extension of the save function for user objects
Syntax
b = saveobj(a)
Description
b = saveobj(a)
extends the save function for user objects. When an object is saved to a MAT file, the save function calls the saveobj method for the object's class if it is defined. The saveobj method must have the calling sequence shown; the input argument a is the object in the workspace and the output argument b is the object that the save function saves to the MAT file.
These steps describe how an object is saved from the workspace to a MAT file:
save function detects the object a in the workspace.
saveobj method defined for the object's class, the object a is
saved directly to the MAT file.
saveobj method defined for the object's class, the save function
calls the method passing the workspace object a as an input argument. The
save function saves the return object, b, to the MAT file.
Remarks
saveobj can be overloaded only for user objects. save will not call saveobj for built-in datatypes (such as double).
saveobj is invoked separately for each object in the MAT file. The save function recursively descends cell arrays and structures applying the saveobj method to each object encountered.
See Also
load, loadobj, save