How can I edit variables for a simulation in Simulink?
Afficher commentaires plus anciens
Hi, I am currently using the Foucault's pendulum simulation ( https://www.mathworks.com/help/simulink/examples/modeling-a-foucault-pendulum.html?s_tid=gn_loc_drop ) and I need to be able to change the variables. I see them in the Matlab workspace, but when I edit them, the simulation does not update and switches the workspace back to the original parameters. I don't understand what I am doing wrong, any help would be greatly appreciated.
Réponses (1)
Cam Salzberger
le 14 Sep 2017
Modifié(e) : Cam Salzberger
le 14 Sep 2017
Hello Jasper,
If you check out the model properties, you can see that the InitFcn callback calls this script to set some parameters:
sldemo_foucault_data
I'd suggest making a copy of the model and script somewhere else (just so you're not modifying the original) and ensuring that the model call the new script. Then you can change the parameters in there. Alternatively, you could just remove the Init function in your copied model, and depend on the base workspace for values.
I've let the team know that the text is misleading. They will look into it for a later release.
-Cam
2 commentaires
Jasper Dobbin
le 18 Sep 2017
Cam Salzberger
le 19 Sep 2017
Click on the drop-down next to the gear icon, then click Model Properties. Go to the Callbacks tab. From here, you can modify what happens when various things occur to the model. See this page for more details on what each of the callbacks do.
In your case, you can just delete the code in the InitFcn in your copy of the model. You may want to run the script I mentioned previously first, and then manually modify the values in the workspace.
Catégories
En savoir plus sur Model, Block, and Port Callbacks dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!