Main Content

Units in MATLAB Function Blocks

Units for Input and Output Data

MATLAB Function blocks support the specification of physical units as properties for data inputs and outputs. Specify units by using the Unit (e.g., m, m/s^2, N*m) parameter. When you start typing in the unit field, this parameter provides matching suggestions for units that Simulink® supports. By default, the property is set to inherit the unit from the Simulink signal on the corresponding input or output port. If you select the Data must resolve to Simulink signal object property for output data, you cannot specify units. In this case, output data is assigned the same unit type as the Simulink signal connected to the output port.

To display the units on the Simulink lines in the model, on the Debug tab, select Information Overlays > Units.

Consistency Checking

MATLAB Function blocks check the consistency of the signal line unit from Simulink with the unit setting for the corresponding input or output data in the block. If the units do not match, Simulink displays a warning during model update.

Units for Stateflow Limitations

The unit property settings do not affect the execution of the MATLAB Function block. Simulink checks only consistency with the corresponding Simulink signal line connected to the input or output. It does not check consistency of assignments inside the MATLAB Function blocks. For example, Simulink does not warn against an assignment of an input with unit set to ft to an output with unit set to m. A MATLAB Function block does not perform unit conversions.

Related Topics