Multiple instances of gui when calling from external function
Afficher commentaires plus anciens
I have an external Matlab function that I wish to produce continuously update plots in the GUI created by app designer.
To get the external function to plot on the app GUI (named betaine.mlapp) I created the following public function in the app code space:
methods (Access = public)
function results = plotfit(app,x,y1,y2)
plot(app.UIAxes,x,y1);
hold(app.UIAxes);
plot(app.UIAxes,x,y2,'-b');
results = 0;
end
end
from the external function (*.m) (yo is the observed spectrum, yc is the calculated spectrum):
x = 1:m;
a = betaine;
z = plotfit(a,x,yo,yc);
It plots just fine, but every time it calls plotfit it generates a new instance of the app gui. It does this hundreds of times. How can I get it to continuously update the on the same gui?
3 commentaires
Geoff Hayes
le 13 Fév 2019
Dennis - what is
a = betaine;
? Are you creating a new instance of your app (named betaine?) everytime you call this external function?
Geoff Hayes
le 13 Fév 2019
Dennis' answer moved here
Geoff --
That must be what is happening, but I don't know how to get around it. The plot function is in the app code space, and each time that it is called from an external function it creates a new instance of the app.
Thanks
Geoff Hayes
le 13 Fév 2019
Dennis - perhaps you can re-use the a whenever you call that external function again? Or create the GUI just once - outside of your external function - and then pass this in as an input to your external function. So each time you call the external function (however you do this) you just pass in the GUI that you have already created and it is that GUI that you will call plotfit on. (You may need to post your external function or at least its signature and how you call it so that we can get a better idea of how it is used.)
Réponses (1)
Dennis Bennett
le 13 Fév 2019
0 votes
1 commentaire
Geoff Hayes
le 14 Fév 2019
Dennis - yes, this sounds reasonable. Good luck!
Catégories
En savoir plus sur Develop Apps Using App Designer 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!