Is there any limitation for using set_param(​bdroot,'Si​mulationCo​mmand','Wr​iteDataLog​s'), 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?

回答(1 个)

Swastik Sarkar
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::

类别

Help CenterFile 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!

Translated by