Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Define System Block Icon

This example shows how to define the block icon of a System object™–based block implemented using a MATLAB System block.

Use the CustomIcon Class and Define the Icon

  1. Subclass from custom icon class.

     classdef MyCounter < matlab.System & ...
       matlab.system.mixin.CustomIcon
    
  2. Use getIconImpl to specify the block icon as New Counter with a line break (\n) between the two words.

    methods (Access=protected)
       function icon = getIconImpl(~)
          icon = sprintf('New\nCounter');
       end
    end

Complete Class Definition File with Defined Icon

classdef MyCounter < matlab.System & ...
   matlab.system.mixin.CustomIcon
  
   % MyCounter Count values above a threshold
     
    properties
       Threshold = 1
    end
    properties (DiscreteState)
       Count
    end
 
    methods
       function obj = MyCounter(varargin)
          setProperties(obj,nargin,varargin{:});
       end
    end
 
    methods (Access=protected)
       function setupImpl(obj, u)
          obj.Count = 0;
       end
       function resetImpl(obj)
          obj.Count = 0;
       end
       function y = stepImpl(obj, u)
          if (u > obj.Threshold)
             obj.Count = obj.Count + 1;
          end
          y = obj.Count;
       end
       function icon = getIconImpl(~)
          icon = sprintf('New\nCounter');
       end
    end
end

See Also

|

More About

Was this topic helpful?