How to set unit properties for arrays in simulink?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1620293/image.png)
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 comentarios
Chuguang Pan
el 18 de Feb. de 2024
The three element in your 3x1 signal should have same unit. You can split positionArray into three seperate inputs and set units respectively.
Respuestas (1)
Sreeram
el 22 de En. de 2025 a las 6:34
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 comentarios
Ver también
Categorías
Más información sobre Composite Interfaces en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!