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.

Add Header to MATLAB System Block

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
    end
end

See Also

|

Was this topic helpful?