See if a signal originates from a bus in Simulink

天涯浪子 提交于 2019-12-24 09:48:19

问题


We have an S-Function that does not support bus signals in Simulink, so programmatically I am trying to find a way to determine if the signal type of an inport/outport originates from/is going to a bus so I can demux and mux the signal automatically as needed. Unfortunately, the only block property I can find that reliably tells if the port comes from or goes to a bus is if it inherits properties from the bus, which might not be true in all cases. Any idea on how to figure this out?


回答1:


Well, I got an answer back from Matlab support, I have tried this and tested this and it works, the only thing is that Mathworks recommends using a Bus Selector instead of a DEMUX block. In a nutshell, here is what you do:

  1. Find the handles of all signal lines in the model.
  2. Get the names if you need to, however, I did this using handles and it worked fine.
  3. Compile the model to create the 'CompiledBusType' property.
  4. Obtain the 'CompiledBusType' property of each signal line in the model. Then terminate the compilation mode of the model.

'CompiledBusType' returns 'NOT_BUS', 'VIRTUAL_BUS', and 'NON_VIRTUAL_BUS'.

Hope this question helps someone else out, had to wait a week for Matlab to get back to me.



来源:https://stackoverflow.com/questions/5992774/see-if-a-signal-originates-from-a-bus-in-simulink

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!