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.
In the MATLAB® editor, open the template system object class file,
Source.m.Save a copy of the class file and rename it as
colorSensor.m.Open the
colorSensor.mfile and change the class name tocolorSensor.classdef colorSensor < realtime.internal.SourceSampleTime ... & coder.ExternalDependency ... & matlab.system.mixin.Propagates ... & matlab.system.mixin.CustomIcon ... end
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.
Save the changes to
colorSensor.m.
In the next section, you will Specify Initialization, Output, and Termination Behavior.