MATLAB: Does PAUSE behave differently in a stand-alone application

MATLAB Compiler

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.

Best Answer

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)