Is there any limitation for using set_param(​bdroot,'Si​mulationCo​mmand','Wr​iteDataLog​s'), while starting a simulation using 'sim' command?

4 vues (au cours des 30 derniers jours)
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?

Réponses (1)

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

Catégories

En savoir plus sur Model, Block, and Port Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by