Base class for System objects
matlab.System is the base class for System objects. In your class definition file, you must subclass your object from this base class (or from another class that derives from this base class). Subclassing allows you to use the implementation and service methods provided by this base class to build your object. Type this syntax as the first line of your class definition file to directly inherit from the matlab.System base class, where ObjectName is the name of your object:
classdef ObjectName < matlab.System
|cloneImpl||Copy System object|
|getDiscreteStateImpl||Discrete state property values|
|getInputNamesImpl||Names of the input ports of the System block|
|getNumInputsImpl||Number of input arguments passed to step and setup methods|
|getNumOutputsImpl||Number of outputs returned by step method|
|getOutputNamesImpl||Names of System block output ports|
|infoImpl||Information about System object|
|isInactivePropertyImpl||Active or inactive flag for properties|
|loadObjectImpl||Load saved System object from MAT file|
|processTunedPropertiesImpl||Action when tunable properties change|
|resetImpl||Reset System object states|
|saveObjectImpl||Save System object in MAT file|
|setProperties||Set property values from name-value pair inputs|
|setupImpl||Initialize System object|
|stepImpl||System output and state update equations|
|validateInputsImpl||Validate inputs to step method|
|validatePropertiesImpl||Validate property values|
In addition to the attributes available for MATLAB® objects, you can apply the following attributes to any property of a custom System object™.
|Nontunable||After an object is locked (after step or setup has been called), use Nontunable to prevent a user from changing that property value. By default, all properties are tunable. The Nontunable attribute is useful to lock a property that has side effects when changed. This attribute is also useful for locking a property value assumed to be constant during processing. You should always specifiy properties that affect the number of input or output ports as Nontunable.|
|Logical||Use Logical to limit the property value to a logical, scalar value. Any scalar value that can be converted to a logical is also valid, such as 0 or 1.|
|PositiveInteger||Use PositiveInteger to limit the property value to a positive integer value.|
|DiscreteState||Use DiscreteState to mark a property so it will display its state value when you use the getDiscreteState method.|
To learn more about attributes, see Property Attributes in the MATLAB Object-Oriented Programming documentation.
Create a simple System object, AddOne, which subclasses from matlab.System. You place this code into a MATLAB file, AddOne.m.
classdef AddOne < matlab.System %ADDONE Compute an output value that increments the input by one methods (Access=protected) % stepImpl method is called by the step method. function y = stepImpl(~,x) y = x + 1; end end end
Use this object by creating an instance of AddOne, providing an input, and using the step method.
hAdder = AddOne; x = 1; y = step(hAdder,x)
Assign the Nontunable attribute to the InitialValue property, which you define in your class definition file.
properties (Nontunable) InitialValue end