When many figure windows present, the pause command doesn't work

11 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

CS Researcher
CS Researcher il 1 Mag 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 Commento
Kyle Schwartz
Kyle Schwartz il 2 Mag 2016
Modificato: Kyle Schwartz il 2 Mag 2016
I think you are misunderstanding/misreading. All the figure windows are open at the end of the example. Tic (starting the timer) is called AFTER the figures are created, at least in the lines of code. The "close all" command on the first line is just to show that the workspace/windows/etc. are all clear/empty/fresh. Please try the above lines (repeated here) with 500 figs without the "close all; clear all; clc;" line after a fresh restart of Matlab. Wait until all the figures are created to press enter (w/ figure window focus OR w/ command line focus), and it'll take forever to give you the carrots. And i do mean "forever" - as in, I give up after 5 minutes because that is obviously wrong/bad. I have to press ctrl+c to get back to a functioning matlab.
Nfigures = 500;
for iFig = 1:Nfigures;
figure;
end;
disp('Wait until all fig windows are created, then Press enter to continue...');
tic; % HERE'S THE TIC command (note, there is no close all command after this!)
pause;
disp('This text should display as soon as you press enter and give you double carrots');
toc
I really doubt this is a specific "physical computer build" problem since it is happening on 2 different computers in our office. But I want to see if other people are having this problem. Have you tried the lines of code?

Accedi per commentare.

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by