Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Define 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)
          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?