msgbox body text does not show up
27 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Fangjun Jiang
5 minutes ago
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 Comments
Mathieu NOE
about 5 hours ago
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 Comments
Mathieu NOE
about 2 hours ago
Edited: Mathieu NOE
about 1 hour ago
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
23 minutes ago
Edited: Walter Roberson
22 minutes ago
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)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!