matlab.System class

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 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.

Class Attributes

Abstract
true
HandleCompatible
true
StrictDefaults
false

For information on class attributes, see Class Attributes.

Methods

expand all

Examples

collapse all

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 and modify the default code 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.

adder = AddOne;
x = 1;
adder(x)
ans = 2

More About

expand all

Introduced in R2011b