annotations

Control appearance of Simscape block based on the component

Syntax

annotations
   [Id1, Id2] : ExternalAccess=value;
   Icon = 'filename';
   [param1, param2] : UnitDropdown = common
end

Description

annotations begins the annotations section, which is terminated by an end keyword. The annotations section in a component file lets you provide annotations that control various cosmetic aspects of a Simscape™ block generated from this component.

Use the annotations section to:

  • Define conditional visibility of component members, such as parameters, variables, and nodes, in block icons and dialog boxes.

  • Specify a custom block icon and change it based on the block variant.

  • Prepopulate a unit drop-down list for a parameter in the block dialog box with commonly used units.

Examples

The following example hides inapplicable parameters from the block dialog box based on the control parameter value.

component MyPipe
  parameters
    circular  = true;             % Circular pipe?
    d_in      = { 0.01, 'm' };    % Pipe internal diameter
    area      = { 1e-4, 'm^2' };  % Noncircular pipe cross-sectional area
    D_h       = { 1.12e-2, 'm' }; % Noncircular pipe hydraulic diameter
  end
  if circular 
  % Hide inapplicable parameters
    annotations
       [area, D_h] : ExternalAccess=none;
    end
    equations
       % First set of equations, for circular pipe 
    end
  else
  % Hide inapplicable parameter
    annotations
       d_in : ExternalAccess=none;
    end
    equations
       % Second set of equations, for noncircular pipe 
    end
  end
  [...] % Other parameters, variables, branches, equations
end

The next example exposes a thermal port H and changes the customized block icon based on the control parameter value.

parameters
    thermal_effects = false; % Model thermal effects?
end
nodes (ExternalAccess=none)
   H = foundation.thermal.thermal; 
end
if thermal_effects 
  % Use icon with additional thermal port
    annotations
       H : ExternalAccess=modify;
       Icon = 'pipe_thermal.jpg';
    end
end

The following example specifies that the drop-down list for the Gain parameter includes a list of common units, such as those available in the Simulink-PS Converter and the PS-Simulink Converter block dialog boxes.

annotations
    Gain : UnitDropdown = common
end
 

Introduced in R2019a