You can specify physical units on Simulink® signals. For details, see Units in Simulink (Simulink).
Interface blocks, such as Simulink-PS Converter and PS-Simulink Converter, handle the boundary between the Simscape™ physical network and the Simulink blocks connected to it. These converter blocks also handle the physical signal units:
On a Simulink-PS Converter block, you specify the unit using the Input signal unit parameter. This parameter defines the unit of the physical signal at the PS output port of the block, which serves as the input signal for the Simscape physical network.
On a PS-Simulink Converter block, you specify the unit using the Output signal unit parameter. This unit must be commensurate with the unit of the input physical signal coming into the block. The block applies a gain equal to the conversion factor before outputting the Simulink signal.
If you specify a physical unit on a Simulink signal connected to a Simulink-PS Converter or a PS-Simulink Converter block, the software compares this unit with the unit specified inside the block. If the parameter value does not match the physical unit of the Simulink signal connected to the block, you get a warning.
Simulink unit database is fixed: you cannot add units or
change unit definitions. When you add a new unit to your Simscape unit
registry, by using the
and use this unit inside a Simulink-PS Converter or PS-Simulink Converter
If your unit definition conflicts with the one in the Simulink database, you get a warning about incompatible unit.
If you add a unit that does not exist in the Simulink database, you get a warning about undefined unit.
Note that these warnings apply only to the Simulink database; the Simscape physical network works as expected.
For example, you want to view the motor speed in revolutions
per second, rather than revolutions per minute (
Add a new unit
rps, defined in
pm_addunit('rps', 1/60, 'rpm');
To open the Permanent Magnet DC Motor example model, in the MATLAB® Command Window, type:
Simulate the model. Examine the simulation results in the Motor RPM scope window.
Open the Sensing subsystem (designated as
the block diagram), double-click the PS-Simulink Converter block
rps as the Output
signal unit parameter value.
Rerun the simulation.
The model works correctly, with the scope displaying the results in revolutions per second.
However, the output Simulink signal of the PS-Simulink
Converter block now displays a warning badge, with a message
units 'rps' are undefined. The detailed message
explains that the units are not defined in the Simulink unit
If you issue a
you can see
rps in the return unit list, which
means that the unit is successfully defined in the Simscape unit
registry. In other words, the warning applies only to Simulink unit
To turn off the unit inconsistency warnings, in the MATLAB Command Window, type: