Using a structure for "Variable name" in "To Workspace" block in Simulink
2 views (last 30 days)
Show older comments
Jannik Heuermann
on 21 Aug 2023
Commented: Jannik Heuermann
on 23 Aug 2023
Is there a way to get the To workspace block in simulink to save data in to a structure variable. For example, in one subsystem of my whole model I would like to log data in to the variable name "engine1.speed" and in another subsystem i would like to use "engine2.speed" and "engine2.voltage".
Is this possible?
Thank you in advance!
0 Comments
Accepted Answer
Angelo Yeo
on 22 Aug 2023
You can export Simulink outputs into MATLAB sturcts with "To Workspace" (see here for details) but they would not look like what you want. I believe the easiest workaround is to use MATLAB function by exempting the "assignin" for compiling with "coder.extrinsic".
See the attached file for detailed implementation.
More Answers (0)
See Also
Categories
Find more on Event Functions 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!