msgbox body text does not show up
30 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I'm using a msgbox(...) to let the user know that a calculation is in progress. Once the calculation is done, I delete the msgbox. In MATLAB versions up to R2024b, this worked fine. However, starting in R2025a, the msgbox window and the OK button appear, but the body text does not show up (see screenshots below). Here is a code example to reproduce the problem:
h = msgbox('Calculating result, please wait...');
for i=1:100000000 % consume some time doing calculations
a(i) = 42;
end;
delete(h); % delete the msgbox
Result in MATLAB 2024b: 

Result in MATLAB 2025b: 

Inserting a drawnow() statement after creating the msgbox does not solve the problem.
How can I fix this? Is there an alternative approach to achieve a similar functionality?
Thanks!
0 Commenti
Risposte (2)
Fangjun Jiang
il 4 Dic 2025 alle 12:58
I use waitbar() for this purpose. It could be fancy but don't over-done it.
f=waitbar(0,'in progress','Name','My App');
for k=1:10
pause(1);
waitbar(k/10, f);
end
0 Commenti
Mathieu NOE
il 4 Dic 2025 alle 13:02
seems to me now you have to use strings (double quote) and no more char array
this works for me (R2025a)
h = msgbox("Calculating result, please wait..."); % input is a string ""
for i=1:20 % consume some time doing calculations
a(i) = 42;
pause(0.1)
end
delete(h); % delete the msgbox
5 Commenti
Mathieu NOE
il 4 Dic 2025 alle 16:26
Modificato: Mathieu NOE
il 4 Dic 2025 alle 16:26
seems to me a quick workaround is to ad a bit of pause before you start the long computation loop - in my understanding , this 0.1 s pause will let matlab finish the display of the msgbox text.
this seem to do the trick on my side :
h = msgbox("Calculating result, please wait...");
pause(0.1)
for i=1:5e7 % consume some time doing calculations
a(i) = i;
end
delete(h); % delete the msgbox
Walter Roberson
il 4 Dic 2025 alle 17:33
Modificato: Walter Roberson
il 4 Dic 2025 alle 17:33
I experimented with putting in a drawnow() before the loop. I thought at first that it worked, but I was mistaken; either way the text of the message box does not show up until after the loop (R2025b)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
