How do I get a pointer to a structure for in/out parameters
2 views (last 30 days)
Show older comments
Cédric Pariset
on 19 Apr 2022
Edited: Mark McBroom
on 26 Apr 2022
Hello,
I don't know how I can go from this simple calculation function:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/969210/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/969210/image.png)
to a C prototype that is more like Calculation(struct_in *pt_in, struct_out *pt_out) rather than Calculation(real_T input, real_T input1, real_t input2, real_T input3, real_T output) ?
Is there any way to have this automatically? Or do I need to create a specific bus/structure?
Thanks,
Best regards
0 Comments
Accepted Answer
Mark McBroom
on 26 Apr 2022
Edited: Mark McBroom
on 26 Apr 2022
A non-virtual bus can be used to hold the input signals and a second non-virtual bus for the output signals. This will result in a C structure in the generated code. You can then use the code mappings editor to specify pass-by reference for the input bus/struct. This should result in your desired function prototype.
0 Comments
More Answers (0)
See Also
Categories
Find more on Simulink Coder 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!