Display images in a loop without user intervention

In Matlab, I have a loop that performs operations on arrays. I would like to display an array at each iteration (for example, using "imagesc"), but without user intervention.

I can get Matlab to update the displayed shape by inserting the "pause" command after imagesc, but it needs to be canceled by pressing a key. Without the pause command, this number is not updated until the end of the cycle.

Is there a way to update the shape at each iteration of the loop?

+4
source share
2 answers

Try using the Matlab drawnow after the graphic code in a loop.

drawnow forces windows with numbers and their children to be updated and resets the system event queue. Any callbacks generated by incoming events (such as mice or key events) are sent before the descent is returned.

+4
source

If drawnow updates too fast, you can improve the frame rate a bit with pause(time_in_seconds) . For example, to pause for 0.5 second, use

 for ... % plot stuff pause(0.5); end 
+2
source

Source: https://habr.com/ru/post/1393171/


All Articles