From: Cesare on
Hello everyone!
I've an issue with IMRECT (Matlab 2009b). After calling

h = imrect(gca);
wait(h);

it is possible to use GETPOSITION to obtain the position of the drawn rectangle. The problem comes if the user decides to press the DEL button thus deleting the rectangle that he/she is drawing. If the rectangle has been deleted, MATLAB returns an error when calling GETPOSITION. How can I detect whether the rectangle has been deleted?
Many thanke,
Cesare
From: Ashish Uthama on
On Wed, 24 Feb 2010 04:15:06 -0500, Cesare <cmfornewsgroup(a)gmail.com>
wrote:

> Hello everyone!
> I've an issue with IMRECT (Matlab 2009b). After calling
>
> h = imrect(gca);
> wait(h);
>
> it is possible to use GETPOSITION to obtain the position of the drawn
> rectangle. The problem comes if the user decides to press the DEL button
> thus deleting the rectangle that he/she is drawing. If the rectangle has
> been deleted, MATLAB returns an error when calling GETPOSITION. How can
> I detect whether the rectangle has been deleted?
> Many thanke,
> Cesare

Protect your getPosition call with isvalid(h)
From: Cesare on
"Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.u8mx3xo0a5ziv5(a)uthamaa.dhcp.mathworks.com>...
> On Wed, 24 Feb 2010 04:15:06 -0500, Cesare <cmfornewsgroup(a)gmail.com>
> wrote:
>
> > Hello everyone!
> > I've an issue with IMRECT (Matlab 2009b). After calling
> >
> > h = imrect(gca);
> > wait(h);
> >
> > it is possible to use GETPOSITION to obtain the position of the drawn
> > rectangle. The problem comes if the user decides to press the DEL button
> > thus deleting the rectangle that he/she is drawing. If the rectangle has
> > been deleted, MATLAB returns an error when calling GETPOSITION. How can
> > I detect whether the rectangle has been deleted?
> > Many thanke,
> > Cesare
>

Thanks a lot, it worked!
> Protect your getPosition call with isvalid(h)
 | 
Pages: 1
Prev: motor speed measurement
Next: textbox in figure