Documentation Center

  • Trial Software
  • Product Updates

Add Header to System Block Dialog

This example shows how to add a header panel to a System object™–based block implemented using a MATLAB System block.

Define Header Title and Text

This example shows how to use getHeaderImpl to specify a panel title and text for the MyCounter System object.

If you do not specify the getHeaderImpl, the block does not display any title or text for the panel.

You always set the getHeaderImpl method access to protected because it is an internal method that end users do not directly call or run.

methods(Static,Access=protected)
   function header = getHeaderImpl
      header = matlab.system.display.Header('MyCounter',...
        'Title','My Enhanced Counter');
   end
end

Complete Class Definition File with Defined Header

 classdef MyCounter < matlab.System
  
   %MyCounter Count values
     
    properties
       Threshold = 1
    end
    properties (DiscreteState)
       Count
    end
 
    methods(Static,Access=protected)
      function header = getHeaderImpl
         header = matlab.system.display.Header('MyCounter',...
           'Title','My Enhanced Counter',...
           'Text', 'This counter is an enhanced version.');
      end
    end

    methods (Access=protected)
       function setupImpl(obj,u)
          obj.Count = 0;
       end
       function y = stepImpl(obj,u)
          if (u > obj.Threshold)
             obj.Count = obj.Count + 1;
          end
          y = obj.Count;
       end
       function resetImpl(obj)
          obj.Count = 0;
       end
              function N = getNumInputsImpl(obj)
          N = 1; 
       end
       function N = getNumOutputsImpl(obj)
          N = 1; 
       end
    end
end

See Also

|

Was this topic helpful?