matlab.System class

Package: matlab

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

    Note:   You must set Access = protected for each matlab.System method you use in your code.


cloneImplCopy System object
getDiscreteStateImplDiscrete state property values
getInputNamesImplNames of the input ports of the System block
getNumInputsImplNumber of input arguments passed to step and setup methods
getNumOutputsImplNumber of outputs returned by step method
getOutputNamesImplNames of System block output ports
infoImplInformation about System object
isInactivePropertyImplActive or inactive flag for properties
loadObjectImplLoad saved System object from MAT file
processTunedPropertiesImplAction when tunable properties change
releaseImplRelease resources
resetImplReset System object states
saveObjectImplSave System object in MAT file
setPropertiesSet property values from name-value pair inputs
setupImplInitialize System object
stepImplSystem output and state update equations
supportsMultipleInstanceImplSupport System object in Simulink For Each subsystem
validateInputsImplValidate inputs to step method
validatePropertiesImplValidate 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™.

NontunableAfter 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 specify properties that affect the number of input or output ports as Nontunable.
LogicalUse 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.
PositiveIntegerUse PositiveInteger to limit the property value to a positive integer value.
DiscreteStateUse 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.


expand all

Create a Basic System Object

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;

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)
Was this topic helpful?