Simulink.Bus and Embedded Coder
9 views (last 30 days)
Show older comments
I have a few Matlab files that work correctly and implement the functionality I need. I am now trying to port them to Simulink/Embedded Coder using the "Matlab Function" block. After resolving a number of "not supported" type problems, I am stuck on a problem that I don't know how to resolve.
The issue is this- the Matlab functions use a structure to keep track of the system state. They modify the state and pass it on to each other. Embedded Coder indicated that structs were not supported, so I added the following line that I found in a Matlab blog post- "outputState = Simulink.Bus.createObject(state);"
That seemed to improve things in that Embedded Coder got "farther". Now, though, it says the following- "Function 'Simulink.Bus' is not supported for code generation. Consider adding coder.extrinsic('Simulink.Bus') at the top of the function to bypass code generation." I tried adding the extrinsic, but it just came up with another error.
Can you use structs in Embedded Coder? If so, what do I need to do. I could break the state struct into individual values/arrays, but it would be very ugly and painful. Thanks for your time and help.
0 Comments
Accepted Answer
Kaustubha Govind
on 5 Nov 2012
You need to specify the Bus type on the Ports and Data Manager of the MATLAB Function block, not in the MATLAB code itself. Please see Attach Bus Signals to MATLAB Function Blocks.
2 Comments
Kaustubha Govind
on 6 Nov 2012
Signals whose size changes during simulation are called variable-size signals. I don't think variable-size signals can have an empty size (at least as of R2012b), but you can certainly have a variable-size signal as an element of a bus. See How can I create an output bus with variable dimensions using a structure in Embedded MATLAB?
More Answers (0)
See Also
Categories
Find more on Timers and Scheduling in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!