Main Content

loadObjectImpl

Class: matlab.System

Load System object from MAT file

Syntax

loadObjectImpl(obj,s,wasInUse)

Description

loadObjectImpl(obj,s,wasInUse) implements the code to load a saved System object™ from a structure, s, or from a MAT file. If the object was in use when saved, the wasInUse input indicates that in-use state. Your loadObjectImpl method should correspond to your saveObjectImpl method to ensure that all saved properties and data are loaded.

Run-Time Details

End users can use load, which calls loadObjectImpl to load a saved System object into their workspace.

Method Authoring Tips

You must set Access = protected for this method.

Input Arguments

expand all

System object handle used to access properties, states, and methods specific to the object. If your loadObjectImpl method does not use the object, you can replace this input with ~.

Saved data returned from saveObjectImpl.

If the object was in use when saved, the wasInUse is true.

Examples

expand all

Load a saved System object. In this example, the object contains:

  • A child object

  • Protected and private properties

  • A discrete state

It also loads states if the object is in use and calls the loadObjectImpl method.

methods (Access = protected)
  function loadObjectImpl(obj,s,wasInUse)
    obj.child = matlab.System.loadObject(s.child);
    
    obj.protectedprop = s.protectedprop;
    obj.pdependentprop = s.pdependentprop;
    
    if wasInUse
      obj.state = s.state;
    end
    
    loadObjectImpl@matlab.System(obj,s,wasInUse);
  end    
end
Introduced in R2012b