Main Content

outputs

Define component outputs, that is, Physical Signal output ports of block

Syntax

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

Description

outputs begins a component outputs definition block, which is terminated by an end keyword. This block contains declarations for component outputs. Outputs will appear as Physical Signal output ports in the block diagram when the component file is brought into a Simscape™ model.

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.

Specifying an optional comment lets you control the port label and location in the block icon.

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 and location, 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 input port name in the block diagram, location is one of the following strings: left, right, top, bottom.

Examples

The following example declares an output port p, with a default value of 1 Pa, specifying the output port of a hydraulic pressure sensor. In the block diagram, this port will be named Pressure and will be located on the bottom side of the block icon.

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

The next 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

The following example declares an input port I and output port O as untyped identifiers. In the block diagram, the output port will be located on the right side of the block icon. 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; % :right
 end

Version History

Introduced in R2008b