Values of Components in a Matlab app are not updated while a loop is running

0

I have created an app using the App Designer in Matlab. I have a check box called CheckBox and want to access its value from inside a loop, e.g. display it in the console. The way this could be done is

while true
    disp(app.CheckBox.Value);
end

And while it technically works, this only ever displays the value the check box had before the loop started. Even if I change the value by checking and unchecking the box respectively, the value that is read by app.CheckBox.Value remains the same.

If I add a pause(0.1); statement into the loop, then the value is able to update, but that slows down the loop significantly. Is there any other way to make sure the value of the check box (and any other component in the app) is updated correctly without having to pause the entire program?

LukasFun

Posted 2019-12-04T13:07:40.590

Reputation: 1

Answers

0

The trick is done by adding drawnow; to the loop, which forces a gui update but doesn't add a deliberate delay.

LukasFun

Posted 2019-12-04T13:07:40.590

Reputation: 1