Main Content

inputs

Define component inputs, that is, physical signal input ports of block

Parent Section: component

Syntax

inputs
    in1 = { value , 'unit' };
end

Description

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

Each input 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 declares a component input, in1, as a value with unit. value is the initial value. unit is a valid unit string, defined in the unit registry.

inputs
    in1 = { value , 'unit' };
end

If you declare an input without a value and unit, as an untyped identifier, it propagates the signal type (size and unit) based on the component connections in the model. Use the following syntax to declare a component input, in1, as an untyped identifier.

inputs
    in1;
end

Note

During sscbuild validation, or when an input is unconnected in a model, untyped inputs receive the type of unitless scalar, that is, {0, '1'}. Therefore, a component with an untyped input must support the type of the input being resolved to unitless scalar.

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

inputs
    in1 = { value , 'unit' };  % label
end

where label is a string corresponding to the input 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 control port of a pressure source by declaring an input s, with a default value of 1 Pa.

inputs
    s = { 1, 'Pa' };   % Pressure
end
annotations
    s : Side = top;
end

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

This example declares an input I as a row vector of electrical currents. The three signals have a default value of 1 A. The signal initial values may be different, but the unit must be the same.

inputs
   I = { [1 1 1], 'A'}; 
end

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

component MyTransformer
     parameters 
         N = 3; % Number of windings
     end
     inputs
         I = {zeros(N, 1), 'A'}; 
     end
     ....
 end

This example declares an input I as an untyped identifier. The unit and size of the input physical signal at port I are propagated from the connected output port.

inputs
   I;
end

Version History

Introduced in R2008b