Define component inputs, that is, Physical Signal input ports of block
inputs in1 = { value , 'unit' }; end
inputs in1; end
inputs
begins a component inputs definition block, which is terminated by
an end
keyword. This block contains declarations for component
inputs. Inputs will appear as Physical Signal input ports in the block diagram when the
component file is brought into a Simscape™ model.
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.
Specifying an optional comment lets you control the port label and location in the block icon.
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 ssc_build
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 and location, the way you want it to appear in the block diagram, as a comment:
inputs in1 = { 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
.
The following example declares an input port s
,
with a default value of 1 Pa
, specifying the control
port of a hydraulic pressure source. In the block diagram, this port
will be named Pressure and will be located on
the top side of the block icon.
inputs s = { 1, 'Pa' }; % Pressure:top end
The next example declares an input port 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 has to 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
The following example declares an input port 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