Using uifigure to show progress of script
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Johannes
el 28 de Abr. de 2021
Respondida: Johannes
el 28 de Abr. de 2021
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 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!