# How to use of physical units within Simulink systems?

4 views (last 30 days)
Klaus Webers on 17 Oct 2021
Commented: Klaus Webers on 19 Nov 2021
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).
% physical quantities ("signal classes")
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
Conclusion
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)
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Pavan Guntha on 16 Nov 2021
Hello Klaus,
You could use Simscape in order to model systems such as electric motors, hydraulic actuators etc., which supports units for each of the quantities like Resistance, Torque etc., By using Simscape you could overcome the issues which have been mentioned. For more information on Simscape, you could look at the documentation page here. You could also leverage Simscape Onramp to learn basics of Simscape.
Hope this helps!
##### 1 CommentShowHide None
Klaus Webers on 19 Nov 2021
Hello Pavan,
The way units are handeled in Simscape is, ideed, exemplary. However, as the question at hand is to improve (pure) Simulink-models, Simscape is not an option, by definition. Perhaps a suitable unit-handling scheme can be taken into account in future releases?
Thank you anyway.

Sign in to comment.

### Categories

Find more on Troubleshooting in Help Center and File Exchange

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by