From: Jim Hokanson on
When looking at a bunch of a figures I tend to plot them in a loop and then use the pause function to allow keying between plots. Unfortunately if dbstop if error is true, then ctrl+c'ing out of it throws an errror. I tried catching and ignoring the error but the error couldn't be caught. I instead tried waitforbuttonpress, but there is no option to limit this to only a mouse or a keyboard input, which means when I start using the mouse on the figure the plotting continues.

Hopefully the goal is clear, any suggestions or workarounds? Thanks.
From: Jos (10584) on
"Jim Hokanson" <jah104(a)pitt.com> wrote in message <hml6q5$gnu$1(a)fred.mathworks.com>...
> When looking at a bunch of a figures I tend to plot them in a loop and then use the pause function to allow keying between plots. Unfortunately if dbstop if error is true, then ctrl+c'ing out of it throws an errror. I tried catching and ignoring the error but the error couldn't be caught. I instead tried waitforbuttonpress, but there is no option to limit this to only a mouse or a keyboard input, which means when I start using the mouse on the figure the plotting continues.
>
> Hopefully the goal is clear, any suggestions or workarounds? Thanks.

See the help of WAITFORBUTTONPRESS.

function WaitForMouseButton
% WaitForMouseButton - Pause until the user clicks a mouse button
% This function uses the current figure, or creates a new figure of none exists.
while waitforbuttonpress ~= 0 ;
pause(0.1) ; % allow for ctrl-c
end

hth
Jos
From: Jim Hokanson on
Thanks Jos,

I should have clarified on that in my post. That function takes over the mouse listener which means I cannot use the mouse on the figure. i.e. I click on the figure with the mouse and instead of getting the desired function, such as zooming on a figure, I just run another iteration of the loop. I'm thinking I might just use get(gcf,'CurrentCharacter') with a try/catch around it in case it is closed (or something like that).

Jim
From: Jos (10584) on
"Jim Hokanson" <jah104(a)pitt.com> wrote in message <hmm737$ser$1(a)fred.mathworks.com>...
> Thanks Jos,
>
> I should have clarified on that in my post. That function takes over the mouse listener which means I cannot use the mouse on the figure. i.e. I click on the figure with the mouse and instead of getting the desired function, such as zooming on a figure, I just run another iteration of the loop. I'm thinking I might just use get(gcf,'CurrentCharacter') with a try/catch around it in case it is closed (or something like that).
>
> Jim


Perhaps you can put UIWAIT at the end of the iteration and create a button/menu on the figure with UIRESUME as its callback ...

Jos