Converting Simulink Bus with mixed datatypes to an array of doubles

30 次查看(过去 30 天)
Hi,
I've been looking long and hard for a solution to this issue. It's a seemingly simple problem, I have a Simulink bus with a lot of different signals and I need an efficient way of converting this bus with mixed datatypes to a flat (1D) array of doubles. But I can't get it working to fulfill my conditions.
I have tried everything for stateflow charts with matlab functions, to custom matlab functions with a predefined bus object, but nothing works that is efficient enough that can be Code Generated in a reasonable time.
My current solution (more like hack) includes retrieving the hierarchy of the bus using get_param(hdl,'SignalHierarchy') to get the structure of the bus and then convert that to a list and autogenerate an InBus, Cast and OutBus block for each bus signal. This leads to 5 minutes longer build time which isn't really acceptable for my use case.
Any input is appreciated, thank you :)

回答(1 个)

Kiran Kintali
Kiran Kintali 2023-6-3
Can you share your current workaround?
I wonder if this block would be of help in your usecase.
  1 个评论
Hendrik Noack
Hendrik Noack 2025-11-28,14:16
Bus to Vector conversion might only work for bus where all elements have same type.
Further I'm looking for method to convert each element to double but keep bus structure even nested buses.
Later on need convert back the complete structure to original element types.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by