How to use of physical units within Simulink systems?
Consistent use of physical units with all signals, also within subsystems, would be desirable (not only for didactic reasons). Unfortunately, I have not yet found a satisfactory approach to this. So far, I've considered the following alternatives:
Defined Simulink.Signal objects per signal
For each signal in the model, a Simulink.Signal object is created first, including unit specification.
uResistance = Simulink.Signal; uResistance.Unit='V';
uInductance = Simulink.Signal; uInductance.Unit='V';
tMotor = Simulink.Signal; tMotor.Unit='N*m';
tFriction = Simulink.Signal; tFriction.Unit='N*m';
Each signal is then bound to the corresponding object by property "Signal must resolve to Simulink signal object".
- Advantage: Consistent and visible use of units (per InformationOverlay->Units).
- Disadvantage: Impractical, high effort and inflexible regarding model changes. Double signal definition.
Defined Simulink.Signal object per "physical quantity"
For each physical quantity, e.g. voltage or torque, a Simulink.Signal object is created. Important: This object type can be reused multiple times in a Simulink model (setting-dependent).
voltage = Simulink.Signal; voltage.Unit='V';
current = Simulink.Signal; current.Unit='A';
torque = Simulink.Signal; torque.Unit='N*m';
Each individual signal is then bound to a physical quantity (i.e. signal-object).
- Advantage: consistent and visible use of units. Additionally: intuitve plausi-check for consistent physical quantities, e.g. at summation points (by klicking variable voltage in ModelDataEditor). Moderate effort, flexible model adaptation.
- Disadvantage: The individual signal name does no longer appear at the signal line. (although an individual signal name may be assigned, per SignalProperties->CustomLoggingName)
Explicit signal specification block for each signal in the model.
Each signal is defined, incl. unit-propertiy, within the model-layout by application of the SignalSpecification-block.
- Advantage: Continuous and visible units. Individual signal name recognizable.
- Disadvantage: High effort. Confusing model due to loads of "unnecessary" blocks
None of the variants solves the problem satisfactorily. Easy definition of output signal properties / quantities (incl. unit) at each Simulink block would be desirable.
Is there a simple and practicable solution for this?
(if so, of course next steps already foreshadow. Particularly, use of some Simulink.Parameter property to plausi-check physical quantities with Ohm's law at gain transforming current to voltage. And/or proper application of time-unit "A/s -> A" with integrator blocks)