Main Content

outputs

Define component outputs, that is, physical signal output ports of block

Parent Section: component

Syntax

outputs
    out1 = { value , 'unit' };
end

Description

outputs begins a component outputs declaration section, which is terminated by an end keyword. This section contains declarations for component outputs, which correspond to the physical signal output ports of a Simscape™ block generated from the component file.

Each output can be defined as:

  • A value with unit, where value can be a scalar, vector, or matrix. For a vector or a matrix, all signals have the same unit.

  • An untyped identifier, to facilitate unit propagation.

The following syntax defines a component output, out1, as a value with unit. value is the initial value. unit is a valid unit string, defined in the unit registry.

outputs
    out1 = { value , 'unit' };
end

If you declare an output without a value and unit, as an untyped identifier, then the output signal type (size and unit) is based on the input signal type and unit propagation rules. Use the following syntax to declare a component output, out1, as an untyped identifier.

outputs
    out1;
end

You can specify the output port label, the way you want it to appear in the block diagram, as a comment:

outputs
    out1 = { value , 'unit' };  % label:location
end

where label is a string corresponding to the output port name in the block diagram. You can use the Side annotation to specify the port location on the block icon. For more information, see Customize the Names and Locations of the Block Ports.

Examples

expand all

This example shows how you can specify the output port of a pressure sensor by declaring an output p, with a default value of 1 Pa.

outputs
    p = { 1, 'Pa' };   % Pressure
end
annotations
    p : Side = bottom;
end

In a custom block generated from this component, this port will be named Pressure and will be located on the bottom side of the block icon.

This example declares an output port v as a 3-by-3 matrix of linear velocities.

outputs
   v = {zeros(3), 'm/s'}; 
end

You can also reference component parameters in output declarations. For example, you can control the signal size by using a block parameter:

component MyComp
     parameters 
         N = 3; % Matrix size
     end
     outputs
         v = {zeros(N), 'm/s'}; 
     end
     ....
 end

This example declares an input port I and output port O as untyped identifiers. The block propagates the unit and size of the physical signal from port I to port O. For more information, see Physical Signal Unit Propagation.

inputs
   I;
 end
 outputs
   O;
end

Version History

Introduced in R2008b