Pause and restart when my app finished

13 ビュー (過去 30 日間)
Alessandro Alberico
Alessandro Alberico 2019 年 3 月 28 日
回答済み: Marc Youcef 2020 年 11 月 4 日
How can I pause the matlab script until I've closed a matlab app?
In my case, I've an app that serves to select the input of my calculations, but while I'm choosing the input the script continues to run. I need to suspend the script until the user has finished to select the input.
What can I do?
  3 件のコメント
Alessandro Alberico
Alessandro Alberico 2019 年 3 月 29 日
My script in matlab is this
d=fopen('nomi piattaforme.txt');
c=textscan(d,'%s','Delimiter',',');
run scelta.mlapp
a=1;
...
In the app, the lines the make it close are:
% Button pushed function: ConfermaButton
function ConfermaButtonPushed(app, event)
assignin('base','producer',app.Prod_selection.Value)
assignin('base','panel',app.Panel_selection.Value);
assignin('base','platform',app.Platform_selection.Value);
delete(app.Selezione)
end
In 'scelta.mlapp' the user must choose through 3 dropdown menu the parameters that I need for the next steps. Actually, I haven't write my complete code yet, but, anyway I need to get the three outputs before 'a=1'.
e.g.: once, in the script, I tried to use one of these parameters some lines below, and it gave me an error saying that 'panel' was not defined yet, beacuse it actually doesn't exist yet, I haven't yet chosen the parameter from the app.
I hope that it is clearer
Alessandro Alberico
Alessandro Alberico 2019 年 3 月 29 日
編集済み: Alessandro Alberico 2019 年 3 月 29 日
Now I tried to use a 'flag' in this way, and it's quite satisfying:
flag=0;
d=fopen('nomi piattaforme.txt');
c=textscan(d,'%s','Delimiter',',');
run scelta.mlapp
while flag==0
pause(5);
end
a=1
And at the end of the app I assigned to 'flag' the value 1 with "assignin".
Maybe it is not the smartest way, but it works enough...

サインインしてコメントする。

回答 (1 件)

Marc Youcef
Marc Youcef 2020 年 11 月 4 日
There is indeed cleaner way, as explained here:
my_app_handle = my_app;
uiwait(my_app_handle.UIFigure_property)
disp("hello")
hello

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by