Is there any limitation for using set_param(bdroot,'SimulationCommand','WriteDataLogs'), while starting a simulation using 'sim' command?
4 views (last 30 days)
Show older comments
I am trying to get live data from a model with the help of ToWorkspace block.The simulation is started using 'sim' command.A block of the model has a callback 'set_param(bdroot,'SimulationCommand','WriteDataLogs')' to get data.
Is it possible to use this command in this manner? Does MATLAB allows this?
0 Comments
Answers (1)
Swastik Sarkar
on 19 Sep 2024
The writedatalogs command is indeed a recognized Simulink command, but incorporating it into a callback can lead to issues. Specifically, MATLAB may crash shortly after the simulation begins because the command alters the simulation state as it starts.
Instead, using the set_param function with SimulationCommand in the MATLAB Command Window effectively writes data logging variables to the MATLAB Workspace without causing instability.
To execute this properly, use the following command in the MATLAB Command Window:
set_param(mdlname, 'SimulationCommand', 'writedatalogs');
For additional details and guidance, refer to the official documentation::
0 Comments
See Also
Categories
Find more on Model, Block, and Port Callbacks 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!