Converting Simulink Bus with mixed datatypes to an array of doubles

22 visualizaciones (últimos 30 días)
Joël Scholl
Joël Scholl el 2 de Jun. de 2023
Comentada: Hendrik Noack el 28 de Nov. de 2025 a las 14:16
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 :)

Respuestas (1)

Kiran Kintali
Kiran Kintali el 3 de Jun. de 2023
Can you share your current workaround?
I wonder if this block would be of help in your usecase.
  1 comentario
Hendrik Noack
Hendrik Noack el 28 de Nov. de 2025 a las 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions 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!

Translated by