Main Content

Select System Object Template

System objects are used to define the behavior of device driver blocks. Follow these steps to create a customized System object™ by modifying the System object template.

  1. In the MATLAB® editor, open the template system object class file, Source.m.

  2. Save a copy of the class file and rename it as colorSensor.m.

  3. Open the colorSensor.m file and change the class name to colorSensor.

    classdef colorSensor < realtime.internal.SourceSampleTime ...
            & coder.ExternalDependency ...
            & matlab.system.mixin.Propagates ...
            & matlab.system.mixin.CustomIcon
        ...
    end
  4. Change the name of the constructor method to colorSensor.

    methods
            % Constructor
            function obj = colorSensor(varargin)
                % Support name-value pair arguments when constructing the object.
                setProperties(obj,nargin,varargin{:});
            end
    end
    

    Note

    A MATLAB class requires the class name, constructor, and file to be identical.

  5. Save the changes to colorSensor.m.

In the next section, you will Specify Initialization, Output, and Termination Behavior.

Go to top of page