Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the 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

getDiscreteStateImplDiscrete state property values
getNumInputsImplNumber of inputs to the System object
getNumOutputsImplNumber of outputs from System object
infoImplInformation about System object
isInactivePropertyImplInactive property status
isInputSizeLockedImplLocked input size status
loadObjectImplLoad 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 using name-value pairs
setupImplInitialize System object
stepImplSystem output and state update equations
validateInputsImplValidate inputs to System object
validatePropertiesImplValidate property values

Attributes

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 it is called 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.

Examples

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