How to use SimulinkRealTime.target/getsignal on bus signal?
4 views (last 30 days)
Show older comments
The documentation for simulink realtime `getsignal` https://www.mathworks.com/help/slrealtime/api/slrealtime.target.getsignal.html says that the output can be a struct if the signal is a bus.
I made a nonvirtual bus signal. See screenshot below.
The signal is not in the list of signals when I use `tg.ShowSignals = 'on';` and display `tg`. See attached file output.txt
I have tried attaching a gain block to the bus output. The gain block signal is visible and I can call getsignal on it, but getsignal returns a single double which seems to be the first of the 6 bus elements. I want the all 6 elements of my bus in one struct. (I want to use a bus signal and getsignal the bus signal because calling getsignal 6 times is too slow for the matlab program I am trying to write.)
Thanks in advance for any help.

2 Comments
David Balbuena
on 18 Aug 2025
The documentation you linked to is for the most recent release of MATLAB. I can tell you are in R2020a or earlier because the name of the API changed in R2020b (see R2020b Simulink Real-Time Major Update - MATLAB & Simulink).
I recommend checking the installed version of the documentation for your release, since the online doc isn't available for those releases. The behavior you're seeing may be a limitation.
If you're able to upgrade, I know for sure you can get the value of bus signals in R2021a and later.
Answers (0)
See Also
Categories
Find more on Target Computer Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!