Why does PAUSE behave differently in a stand-alone application?

3 views (last 30 days)
The following code, when ran within MATLAB, shows a plot in a figure window, when the figure window is focused and ENTER is pressed, the next plot is shown, this behaviour is correct:
function pausetest()
h = plot(rand(10));
pause
h = plot(rand(10));
pause
h = plot(rand(10));
However when compiled as a stand-alone, every time PAUSE is executed, pressing ENTER while the figure window is focused does not have any effect. Instead, the DOS window needs to be selected for the ENTER key to be recognized and the next plot to be shown.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The ability to recognize the ENTER key while the figure window is focused in a stand-alone application is not available in MATLAB Compiler.
To work around this issue, you can create a push button on the figure which advances the figure to the next plot. The following code demonstrates this:
function pausetestbutton()
% Create button.
h = uicontrol('Style','togglebutton','String','Next plot');
plot(rand(10));
waitfor(h,'value');
plot(rand(10));
waitfor(h,'value');
plot(rand(10));
% Remove button.
delete(h)

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!