How to set unit properties for arrays in simulink?
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Chuguang Pan
2024 年 2 月 18 日
The three element in your 3x1 signal should have same unit. You can split positionArray into three seperate inputs and set units respectively.
回答 (1 件)
Sreeram
2025 年 1 月 22 日
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!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!