How to set unit properties for arrays in simulink?

조회 수: 4 (최근 30일)
Kraker
Kraker 2024년 2월 18일
답변: Sreeram 2025년 1월 22일
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
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.
Kraker
Kraker 2024년 2월 18일
Inputs are kinda fixed. I am looking for the way to define different unit for array. It seems like not possible.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sreeram
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!

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by