Unit Consistency Checking and Propagation
Simulink® performs unit consistency checking between components.
Ports that you connect together — sometimes via intermediate
blocks that propagate units — must have the same units. For
example, you cannot connect a port with unit
a port with unit
By default, Simulink shows the mismatch warning when it detects a mismatch in units between two connected ports. You can press Ctrl+D to show mismatched units in your model.
To make this connection valid, you can:
Explicitly set both port units to the same unit.
Set the Unit parameter of one of the connecting ports to
Insert a Unit Conversion block between the mismatched units if they are separated by a scaling factor or offset, or if they are inverse units. These units are convertible. For more information, see Converting Units.
Select the Allow automatic unit conversions configuration parameter. For more information, see Converting Units.
Simulink supports variations on unit expressions. For example,
one port can have a unit of
m/s^2 and a connected
port can have a unit of
m/s/s. In these cases, Simulink does
not display a warning for mismatched units.
When Simulink detects one of these conditions, it displays the inconsistency warning :
Disallowed unit system
Simulink checks the consistency of unit settings and propagates units across component boundaries. In a model that contains a referenced model, Simulink compiles the referenced model independently of the top model. This independent compilation means that the referenced model cannot inherit units from the top model.
If a port in a referenced model has Unit set
inherit, it can inherit a unit from any upstream
or downstream block in the referenced model. If the port does not
inherit a unit from an upstream or downstream block, you can connect
it to a port in the top model with any unit.
Simulink passes units through the following blocks that do not change data, known as noncomputation blocks:
Bus to Vector
Data Type Conversion
If you supply two or more signals with different units to a Mux block, Simulink applies empty units to the vector signal that the Mux block outputs. Vector signals must have a common unit.
If you have a nonvirtual bus in your model (see Types of Composite Signals), Simulink sets the unit of the bus to empty. A nonvirtual bus cannot have a unit. However, if the bus element signals themselves have units, Simulink does not change these.
Simulink does not propagate units through blocks that produce new data as output. When signals with units pass through these blocks, the units of these signals become empty. Examples of blocks that do not preserve units because they produce new data as an output include:
Unit Propagation Between Simulink and Simscape
When modeling physical systems, you might want to integrate components developed in Simulink with components developed in Simscape™ and its associated physical modeling products. Simscape components use physical signals instead of regular Simulink signals. Therefore, you need Simulink-PS Converter (Simscape) and PS-Simulink Converter (Simscape) converter blocks to connect signals between Simulink and Simscape components.
To specify units for the input and output signals of your Simscape component, you can explicitly specify the units on the converter blocks. When you specify units on a PS-Simulink Converter (Simscape) block that converts a signal from Simscape to Simulink, Simulink propagates the unit settings to the connected Simulink port. However, Simulink cannot propagate a signal unit from Simulink into your Simscape component. To do that, you must explicitly specify the unit on the Simulink-PS Converter (Simscape) block. For more information, see Physical Units (Simscape).
- Unit Conversion | Unit System Configuration | Inport | In Bus Element | Outport | Out Bus Element | Signal Specification | MATLAB Function