MATLAB Answers

Why does program execution hang when using "pause?"

301 views (last 30 days)
Phillip Remaker
Phillip Remaker on 11 Apr 2016
Commented: xa zrma on 9 Mar 2020
I am using Windows 10, Matlab R2016a (9.0.0.341360) 64-bit win64 Feb 11, 2016 for the Coursera Machine Learning course. A number of the example programs use the "pause" operator to allow a user to observe some output before continuing.
I have noticed that about 20% of the time, when I press enter at the "pause" section of a program, it will not proceed. I have to press ctrl-c to abort, and then restart the program.
The lower left corner says "Paused: Press any key" but when I press enter, it reports "Busy" in the lower corner and hangs forever.
If I press CTRL-C, I see it is aborting at the PAUSE line.
I usually have to restart MATLAB to get it working again.
Why would "pause" fail this way? Is this a bug or am I doing something wrong?

  4 Comments

Show 1 older comment
Phillip Remaker
Phillip Remaker on 11 Apr 2016
We have about a half dozen people on the Coursera class forums with the problem, so it is not just me. Does the Academic bulk license include the ability to contact support? We have all done a number of workarounds (including writing our own pause.m functions), but I'd think there might be some interest from TMW if we can reproduce.
I hate to consume support resources as an academic user, but I may check in to see if they know about it.
jgg
jgg on 11 Apr 2016
This definitely sounds like a bug in the 2016a distribution. Contact tech support; if several people are experiencing, it can adversely affect a much wider population.
Andreas Goser
Andreas Goser on 12 Apr 2016
With bugs or anticipated bugs, please get in touch with MathWorks support, really doesn't matter what your license type is.

Sign in to comment.

Answers (4)

Phillip Remaker
Phillip Remaker on 2 May 2016
I opened a case with Mathworks and they made the following suggestion:
----
I believe this is a known issue in MATLAB R2016a. Some customers have been able to resolve this issue by including a “drawnow” command immediately before the “pause” command. I would recommend attempting this workaround.
----

sam0037
sam0037 on 14 Apr 2016
Hi,
This is a bug which only occurs in Windows 10. Using Space key to come out of pause mode works, but if Enter key is used instead, it freezes MATLAB. Developers are aware of it and working towards a fix.Currently, the only workaround is to use the Space key instead of Enter to come out of the pause mode.

  6 Comments

Show 3 older comments
Nikita Kuznetsov
Nikita Kuznetsov on 10 Aug 2016
I'm also experiencing the same issue on Windows 7.
Subhobroto Choudhury
Subhobroto Choudhury on 29 Jul 2019
I agree, I experience the same problem with the pause command on Matlab R2016a on a Windows 7 computer.
xa zrma
xa zrma on 9 Mar 2020
I have experienced this issue on my Mac OS Catalina also with R2019b

Sign in to comment.


Likhit
Likhit on 17 Feb 2017
Has anyone found a solution/patch to fix this issue? I am having the same problem, right now with my code. Drawnow and Using the Space does not seem to work well.

  1 Comment

Phillip Remaker
Phillip Remaker on 17 Feb 2017
I will write a new answer based on what was discussed at the Coursera list in April 2016

Sign in to comment.


Phillip Remaker
Phillip Remaker on 17 Feb 2017
Edited: Walter Roberson on 17 Feb 2017
Here is a summary of the April 2016 discussion "Pause Failure Windows 10" ( Coursera Forum ) on the closed Coursera forum for Andrew Ng's Machine Learning class:
Tom Mosher, Mentor:
Another work-around is to define your own new pause.m function, put it in the working folder with your exercise scripts, and have it use the input() command.
K. Grace Kennedy, Mentor:
The instructor is using "pause" so that you can step through sections. You could use MATLAB R2015b. But since Professor Ng has his code divided into sections, I think the best solution is to comment the pauses as you have done and use the run section buttons. Click "Run and Advance" or "Run section" to run one section at a time. This will permanently fix the script and have no effect on the grader.

Tags

Products

Community Treasure Hunt

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

Start Hunting!