MATLAB: App designer, label text is not updated

app designerdesignerlabel;

Hello,
I'm working on an app in Matlab App Designer and I noticed that my calls to change the text of a label or not executed properly. Clicking on a button starts a function, which in turn calls several other functions. I want to give the user some feedback during the function so it is clear that the script didn't crash. Here is my example code:
function do_several_things(app)
app.Label_status.Text = 'Status: Now doing x...';
do_x();
app.Label_status.Text = 'Status: now doing y...';
do_y();
app.Label_status.Text = 'Status: now doing z...';
do_z();
imshow(app.some_img, [], 'Parent', app.ImMain);
app.Label_status.Text = 'Status: Done...';
end
When I run the script, only the last message "Status: Done…" is shown. The functions take around 10 seconds, so I am sure that the other text messages are not shown. I also tried commenting out the last text update and the imshow command, then the script does not display any messages while running and after having finished displays the third text "Status: no dowing z…". Commenting out more showed the same pattern. Why is the text not updated at the correct moment? Is a label the wrong object for my aim and if so what other options do I have?
edit: I am using Matlab 2018a

Best Answer

Use drawnow to force the app to update the label
app.Label_status.Text = 'Status: Now doing x...';
drawnow
do_x();
app.Label_status.Text = 'Status: now doing y...';
drawnow
do_y();
. . .
. . .