unable to run .m or .slx file from GUI pushbutton callback

3 vues (au cours des 30 derniers jours)
SHAMANTH GOWDA
SHAMANTH GOWDA le 24 Avr 2018
Hi
I am not able to run my .m script and simulink model from the GUI callback. I have added the following lines in the push button callback.
run('so.m'); sim('type3.slx');
The .m file takes data from the base workspace, executes and produces a set of values that will get stored in the same workspace. The simulink model uses these workspace values to run and it exports scope data to the workspace. I am able to export the values taken from GUI to the base workspace using assignin command. The error I am getting when I run the GUI is that the .m is not able to access the workspace variable even if present. It says undefined variable.
Is there any other command to run .m files that are outside the GUI code?

Réponses (1)

Amit
Amit le 24 Avr 2018
GUI callback is basically a function which do not share base workspace. So when you calling your script through callback its variables getting created in function workspace of callback and when callback ends, variables also getting removed. That means only during the execution time of your callback, variables are appearing in the workspace.
better you use global variables in script to appear in base workspace.
  2 commentaires
SHAMANTH GOWDA
SHAMANTH GOWDA le 24 Avr 2018
So its not possible to transfer the execution control to the script outside the GUI script? And how about running the model? What command should I use for doing that?
KONGPHET Vorachack
KONGPHET Vorachack le 12 Juin 2020
Hello, I have the same problem as SHAMANTH GOWDA, I try to use global in the GUI, but before the call the sim('name of simulink model'), all the datas for simulation of model are dissapared.

Connectez-vous pour commenter.

Catégories

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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by