Main Content

Customize System Block Appearance

Specify Input and Output Names

Specify the names of the input and output ports of a System object™–based block implemented using a MATLAB System block.

Use getInputNamesImpl and getOutputNamesImpl to specify the names of the input port as “source data” and the output port as “count.”

If you do not specify the getInputNamesImpl and getOutputNamesImpl methods, the object uses the stepImpl method input and output variable names for the input and output port names, respectively. If the stepImpl method uses varargin and varargout instead of variable names, the port names default to empty character vectors.

methods (Access = protected)
   function inputName = getInputNamesImpl(~)
          inputName = 'source data';
   end
   
   function outputName = getOutputNamesImpl(~)
          outputName = 'count';
   end
end

 Complete Class Definition with Named Inputs and Outputs

Add Text to Block Icon

Add text to the block icon of a System object–based block implemented using a MATLAB System block.

  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 between the two words.

    methods (Access = protected)
        function icon = getIconImpl(~)
            icon = {'New','Counter'};
        end
    end

     Complete Class Definition File with Defined Icon

Add Image to Block Icon

Define an image on the block icon of a System object–based block implemented using a MATLAB System block.

  1. Subclass from custom icon class.

    classdef MyCounter < matlab.System & matlab.system.mixin.CustomIcon

  2. Use getIconImpl method to call the matlab.system.display.Icon class and specify the image.

    methods (Access = protected)
        function icon = getIconImpl(~)
            icon = matlab.system.display.Icon('counter.png');
        end
    end

     Complete Class Definition File with Icon Image

See Also

| | | | |

Related Topics