MATLAB Function Reference
  Go to function:
    Search    Help Desk 
saveobj    See Also

User-defined extension of the save function for user objects

Syntax

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:

   1.
The save function detects the object a in the workspace.
   2.
If there is no saveobj method defined for the object's class, the object a is saved directly to the MAT file.
   3.
If there is a 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



[ Previous | Help Desk | Next ]