Is there any limitation for using set_param(bdroot,'SimulationCommand','WriteDataLogs'), while starting a simulation using 'sim' command?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Swastik Sarkar
2024-9-19
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!