This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

matlab.System class

Package: matlab

Base class for System objects

Description

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.

Methods

allowModelReferenceDiscreteSampleTimeInheritanceImplModel reference sample time inheritance status for discrete sample times
getDiscreteStateImplDiscrete state property values
getGlobalNamesImplGlobal variable names for MATLAB System block
getHeaderImplHeader for System object display
getImpulseResponseLengthImplDefine length of input effects for dataflow subsystems
getInputDimensionConstraintImplDefine input dimension constraints for dataflow subsystems
getInputNamesImplNames of MATLAB System block input ports
getNumInputsImplNumber of inputs to the System object
getNumOutputsImplNumber of outputs from System object
getOutputDimensionConstraintImplDefine output dimension constraints for dataflow subsystems
getOutputNamesImplNames of MATLAB System block output ports
getPropertyGroupsImplProperty groups for System object display
getSimulateUsingImplSpecify value for Simulate using parameter
infoImplInformation about System object
isDiscreteStateSpecificationMutableImplControl whether discrete states can change data type
isInactivePropertyImplStatus of inactive property
isInputComplexityMutableImplSet whether System object input complexity can change
isInputDataTypeMutableImplSet whether System object input data type can change
isInputSizeLockedImplStatus of locked input size
isInputSizeMutableImplSet whether System object input size can change
isTunablePropertyDataTypeMutableImplSet whether tunable properties can change data type
loadObjectImplLoad System object from MAT file
processInputSpecificationChangeImplPerform actions when input size, complexity, or data type change
processTunedPropertiesImplAction when tunable properties change
releaseImplRelease resources
resetImplReset System object states
saveObjectImplSave System object in MAT file
setPropertiesSet property values using name-value pairs when creating System object
setupImplInitialize System object
showFiSettingsImplFixed point data type tab visibility for System objects
showSimulateUsingImplVisibility of Simulate using parameter
stepImplSystem output and state update equations
supportsMultipleInstanceImplSupport System object in Simulink For Each subsystem
validateInputsImplValidate inputs to System object
validatePropertiesImplValidate property values of System object

Attributes

You can apply attributes to the System object™ class and properties. To learn more about attributes, see Class Attributes or Property Attributes.

Class Attribute

This table shows attributes that you can apply to the MATLAB® System object class.

Attribute NameDescription
StrictDefaults

Control the defaults for the methods that restrict specification modifications changes:

  • isInputSizeMutableImpl

  • isInputComplexityMutableImpl

  • isInputDataTypeMutableImpl

  • isTunablePropertyDataTypeMutableImpl

  • isDiscreteStateDataTypeMutableImpl

By default, these methods return true. When you add this class attribute, these methods return false by default. By making these methods return false, the specified aspects of the inputs, tunable properties, or discrete states cannot change. You can always implement these methods individually. Customized methods take precedence over the StrictDefaults attribute.

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

Property Attributes

You can apply the following attributes to any property of a custom System object.

NontunableUse Nontunable to prevent a user from changing that 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.
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.

Examples

collapse all

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 when the object is called.
       function y = stepImpl(~,x)
          y = x + 1;
       end    
    end
end

Use this object by creating an instance of AddOne, providing an input, and running the object.

hAdder = AddOne;
x = 1;
hAdder(x);

Assign the Nontunable attribute to the InitialValue property, which you define in your class definition file.

properties (Nontunable)
   InitialValue
end