フィルターのクリア

Using uifigure to show progress of script

2 ビュー (過去 30 日間)
Johannes
Johannes 2021 年 4 月 28 日
回答済み: Johannes 2021 年 4 月 28 日
Hi there,
I'm working on a rather complex and often time consuming script, and so far I inform myself of my progress in the old school way by fprintf('',x,y,z) the progress on my screen. But the command window becomes rather cluttered because of this, and for this + some other reasons I'd like it to simply be a dialogue box popping up at the top.
So here's what I've been doing:
The following is initialised before the while and for loops are initialised.
ui.prog.fig=uifigure('Name','Progress','HandleVisibility', 'on','WindowStyle','modal');
ui.prog.fig.Position(3:4)=[400 100];ui.prog.fig.Position(1:2)=[1 1080-ui.prog.fig.Position(4)-30];
ui.prog.lblrqp=uilabel(ui.prog.fig,'Text','Initiating','Position',[10 30 100 40],'FontSize',16);
ui.prog.lblrqp.Position(3)=ui.prog.fig.Position(3)-2*ui.prog.lblrqp.Position(1);
Then the while loops operate. These are terminated by the break command once the conditions are met. Towards of the end of the loops we thus have this:
ui.prog.lblrqp.Text=sprintf('%s %s Mode %d\nrqp=%d WL=%.4fs not identified: %d',strCOR{COR},strID{IDENT},MODE(mode),rqp,Lw,nonident);
My intention here being to update the text in the ui figure as long as this runs.
However, this hasn't really worked out. The uifigure seems to only pop up once all the loops have finalised, making all of this quite pointless.
Is there a workaround or is there a different type of dialogue box that can do this?
Note also that I assumed that closing and initialising a new window every time could be unnecessarily processing power consuming, hence why I tried to do it by just updating a label inside an existing figure.
Also I did the
'WindowStyle','modal'
hoping that the window would always be at the top, but whether I had it included or not had no effect as the window sadly wasn't created in the first place until too late.
  2 件のコメント
Stephen23
Stephen23 2021 年 4 月 28 日
Johannes
Johannes 2021 年 4 月 28 日
I tested it out by adding a drawnow command after the text updating line, both with and without limitrate. The figure does now show earlier than before, but it doesn't update the text, so it's stuck at "Initialising".

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

採用された回答

Johannes
Johannes 2021 年 4 月 28 日
Ok I figured it out now, with help from Stephen Cobeldick, but he only provided the link and here's an in-depth explanation if anyone's interested: The solution is to add a drawnow limitrate command.
However, using "ui.prog.lblrqp.Text" (the part before ".Text" being the name given to the label) doesn't work, even with the drawnow. This one can't update it until after the whileloop is finished. Instead you have to reference the label directly. In my case: "ui.prog.fig.Children.Text". The part before ".Children.Text" being the name I gave to the figure.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by