Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

loadobj

Customize load process for objects

Syntax

b = loadobj(a)

Description

b = loadobj(a) is called by the load function if the class of a defines a loadobj method. load returns b as the value loaded from a MAT-file.

Define a loadobj method when objects of the class require special processing when loaded from MAT-files. If you define a saveobj method, then define a loadobj method to restore the object to the desired state.

Define loadobj as a static method so it can accept as an argument whatever object or structure that you saved in the MAT-file.

When loading a subclass object, load calls only the subclass loadobj method. If a superclass defines a loadobj method, the subclass inherits this method. However, it is possible that the inherited method does not perform the necessary operations to load the subclass object. Consider overriding superclass loadobj methods.

If any superclass in a class hierarchy defines a loadobj method, then the subclass loadobj method must ensure that the subclass and superclass objects load properly. Ensure proper loading by calling the superclass loadobj (or other methods) from the subclass loadobj method.

Input Arguments

a

The input argument, a, can be:

  • The object as loaded from the MAT-file.

  • A structure created by load (if load cannot resolve the object).

  • A structure returned by the saveobj method that was saved instead of the object.

Implement your loadobj method to work with scalar objects or structures. When you have saved an object array, load calls loadobj on each element of the saved array.

Output Arguments

collapse all

Object passed to load function by MATLAB.The value returned by a class loadobj method is typically an object of the class being loaded. However, the loadobj method can return an object of a different class or an updated object that matches a new class definition.

Introduced before R2006a

Was this topic helpful?