How to set unit properties for arrays in simulink?

4 Ansichten (letzte 30 Tage)
Kraker
Kraker am 18 Feb. 2024
Beantwortet: Sreeram am 22 Jan. 2025
I have 3x1 positionArray such as [latitude, longitude, altitude] and units are [rad,rad,m].
This array is in the input for simulink. Is there any way to define different units for array in simulink?
In the "Signal Attributes" section, i tried:
rad, rad, m
rad_rad_m
[rad,rad,m]
{rad,rad,m}
nothing works.
Unit specifications are explained in following link, but there is no information about array units.
https://www.mathworks.com/help/simulink/ug/units-in-simulink.html
  2 Kommentare
Chuguang Pan
Chuguang Pan am 18 Feb. 2024
The three element in your 3x1 signal should have same unit. You can split positionArray into three seperate inputs and set units respectively.
Kraker
Kraker am 18 Feb. 2024
Inputs are kinda fixed. I am looking for the way to define different unit for array. It seems like not possible.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sreeram
Sreeram am 22 Jan. 2025
Hi Kraker,
Simulink does not currently support assigning different units for individual elements of an array directly. Units in Simulink are applied at the signal level, which means the same unit applies to the entire array.
A possible workaround is to create a custom "Bus" object. A Simulink Bus allows defining multiple elements with individual names, data types, and units. Here is how you can define it programmatically:
elems(1) = Simulink.BusElement;
elems(1).Name = 'Latitude';
elems(1).Unit = 'rad';
elems(2) = Simulink.BusElement;
elems(2).Name = 'Longitude';
elems(2).Unit = 'rad';
elems(3) = Simulink.BusElement;
elems(3).Name = 'Altitude';
elems(3).Unit = 'm';
positionBus = Simulink.Bus;
positionBus.Elements = elems;
For more information on "Bus" objects, the following documentation might help:
I hope this helps!

Kategorien

Mehr zu Event Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by