Using a structure for "Variable name" in "To Workspace" block in Simulink

2 views (last 30 days)
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!

Accepted Answer

Angelo Yeo
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)

Categories

Find more on Event Functions in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!