Multiple instances of gui when calling from external function
이전 댓글 표시
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
Geoff Hayes
2019년 2월 13일
Dennis - what is
a = betaine;
? Are you creating a new instance of your app (named betaine?) everytime you call this external function?
Geoff Hayes
2019년 2월 13일
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
2019년 2월 13일
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.)
답변 (1개)
Dennis Bennett
2019년 2월 13일
0 개 추천
댓글 수: 1
Geoff Hayes
2019년 2월 14일
Dennis - yes, this sounds reasonable. Good luck!
카테고리
도움말 센터 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!