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 methods 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
Note
You must set Access = protected
for each matlab.System
method
you use in your code.
The matlab.System
class is a handle
class.
Abstract | true |
HandleCompatible | true |
StrictDefaults | false |
For information on class attributes, see Class Attributes.
setupImpl | Initialize System object |
stepImpl | System output and state update equations |
resetImpl | Reset System object states |
releaseImpl | Release resources |
getDiscreteStateImpl | Discrete state property values |
infoImpl | Information about System object |
isDoneImpl | End-of-data flag |
isInactivePropertyImpl | Status of inactive property |
isTunablePropertyDataTypeMutableImpl | Set whether tunable properties can change data type |
isDiscreteStateSpecificationMutableImpl | Control whether discrete states can change data type |
processTunedPropertiesImpl | Action when tunable properties change |
setProperties | Set property values using name-value pairs when creating System object |
validatePropertiesImpl | Validate property values of System object |
getNumInputsImpl | Number of inputs to the System object |
getNumOutputsImpl | Number of outputs from System object |
getNumInputs | Number of inputs required to call the System object |
getNumOutputs | Number of outputs from calling the System object |
isInputComplexityMutableImpl | Set whether System object input complexity can change |
isInputDataTypeMutableImpl | Set whether System object input data type can change |
isInputSizeMutableImpl | Set whether System object input size can change |
nargin | Number of input arguments for System object |
nargout | Number of output arguments for System object |
processInputSpecificationChangeImpl | Perform actions when input size, complexity, or data type change |
validateInputsImpl | Validate inputs to System object |
loadObjectImpl | Load System object from MAT file |
saveObjectImpl | Save System object in MAT file |
allowModelReferenceDiscreteSampleTimeInheritanceImpl | Model reference sample time inheritance status for discrete sample times |
getSimulateUsingImpl | Specify value for Simulate using parameter |
getSimulinkFunctionNamesImpl | Register Simulink function names used in your System object |
showFiSettingsImpl | Fixed point data type tab visibility for System objects |
supportsMultipleInstanceImpl | Support System object in Simulink For Each subsystem |
showFiSettingsImpl | Fixed point data type tab visibility for System objects |
getSimulateUsingImpl | Specify value for Simulate using parameter |
supportsMultipleInstanceImpl | Support System object in Simulink For Each subsystem |
isInputDirectFeedthroughImpl | Direct feedthrough status of input |
outputImpl | Output calculation from input or internal state of System object |
updateImpl | Update object states based on inputs |
getDiscreteStateSpecificationImpl | Discrete state size, data type, and complexity |
getOutputDataTypeImpl | Data types of output ports |
getOutputSizeImpl | Sizes of output ports |
isOutputComplexImpl | Complexity of output ports |
isOutputFixedSizeImpl | Fixed- or variable-size output ports |
propagatedInputComplexity | Complexity of input during Simulink propagation |
propagatedInputDataType | Data type of input during Simulink propagation |
propagatedInputFixedSize | Fixed-size status of input during Simulink propagation |
propagatedInputSize | Size of input during Simulink propagation |
getIconImpl | Name to display as block icon |
getHeaderImpl | Header for System object display |
matlab.system.display.Action | Custom button |
matlab.system.display.Header | Header for System objects properties |
matlab.system.display.Icon | Custom icon image |
matlab.system.display.Section | Property group section for System objects |
matlab.system.display.SectionGroup | Section group for System objects |
getInputNamesImpl | Names of MATLAB System block input ports |
getOutputNamesImpl | Names of MATLAB System block output ports |
getGlobalNamesImpl | Global variable names for MATLAB System block |
showSimulateUsingImpl | Visibility of Simulate using parameter |
createSampleTime | Create sample time specification object |
getSampleTime | Query sample time |
getSampleTimeImpl | Specify sample time type, offset time, and sample time |
getCurrentTime | Current simulation time in MATLAB System block |
allowModelReferenceDiscreteSampleTimeInheritanceImpl | Model reference sample time inheritance status for discrete sample times |
getImpulseResponseLengthImpl | Define length of input effects for dataflow subsystems |
getInputDimensionConstraintImpl | Define input dimension constraints for dataflow subsystems |
getOutputDimensionConstraintImpl | Define output dimension constraints for dataflow subsystems |
This example shows how to author a basic System object called AddOne
.
In MATLAB, select New > System object > Basic. A new editor window opens with default syntax and comments for a new System object.
Rename the class AddOne
. Modify the default template so your class looks like this:
classdef AddOne < matlab.System % ADDONE Compute an output value that increments the input by one methods (Access = protected) % Implement algorithm. Calculate y as a function of input x. function y = stepImpl(~,x) y = x + 1; end end end
Use this object by creating an instance of AddOne
and running the object with input.
addingObject = AddOne; x = 5; addingObject(x)
ans = 6
You can apply attributes to the System object™ class and properties. To learn more about attributes, see Class Attributes or Property Attributes.
This table shows attributes that you can apply to the MATLAB System object class.
Attribute Name | Description |
StrictDefaults | Control the defaults for the methods that restrict specification modifications changes:
By default, these methods return For System objects used in Simulink®, this attribute only restricts input size changes because Simulink already restricts complexity and data type for tunable properties, inputs, and states. |
Specify the class attribute value in parentheses followed by the class name, for example:
classdef (StrictDefaults) MySystemObject < matlab.System
You can apply the following attributes to any property of a custom System object.
Nontunable | Use Nontunable to prevent changes to a property
value while the object is in use. By default, all properties are tunable.
The Nontunable attribute is useful to lock down 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 specify properties that affect the number
of input or output ports as Nontunable . |
DiscreteState | Use DiscreteState to mark a property so it will display its state value when you
use the getDiscreteState method. |
You have a modified version of this example. Do you want to open this example with your edits?