When many figure windows present, the pause command doesn't work
4 views (last 30 days)
Show older comments
When Matlab plots many figures and then the pause command, it does not recognize that the user presses enter to move on to the next line of code. I have to hit ctrl+c to break out of the code. If you use Nfigures = 5, it usually works pretty fast, like you'd expect (toc says ~1sec). If you use Nfigures = 50, it will just take quite a while (20+seconds, or forever, but it should take 0sec) after you hit enter, or hit enter a bunch. If you use Nfigures=500 it will basically never continue past the pause, no matter how many times you hit enter, no matter how long you wait.
Clarifications: I see that "Press enter to continue..." shows up before the figures are created. That's fine. I'm not talking about that. Wait until all 500 figures are created. Press enter with the figures in focus, nothing happens. Click back Into the command window and press enter, nothing happens. Press enter a whole bunch, still nothing. Then eventually you'll have to press ctrl+c. To be clear, I'm not complaining about it taking whatever time it takes to generate 5 or 500 figures. That's fine. I'm complaining about that the PAUSE function does not recognize that I have pressed enter after it is done with plotting/figure generation.
I think this is some kind of bug in Matlab. It happens on my computer and also an officemate's computer. Sufficiently different computer setups, and also sufficiently "not old crummy computer" setups (both i7, etc.) Can someone else confirm? Am I doing something wrong?
close all; clear all; clc;
Nfigures = 500;
for iFig = 1:Nfigures;
figure;
end;
disp('Press enter to continue...'); tic; pause;
disp('This text should display as soon as you press enter and give you double carrots');
toc
Comp1: Matlab 2016a Windows 7pro 64bit Intel core-i7 3770 3.4GHz 8GB Ram. Comp2: Matlab 2016a Windows 10 64bit Intel core-i7 5820 3.3GHz 16GB Ram
0 Comments
Answers (1)
CS Researcher
on 1 May 2016
I think it takes 20+ seconds because you first close all the open figures while the tic has already started. It computes all the time (time for you to close all the open figures and press enter). Press enter by going to the command window without closing all the figures and it will be fine.
1 Comment
See Also
Categories
Find more on Install Products 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!