From: Steven Lord on

"Nicky " <nick(a)mytrashmail.com> wrote in message
news:hklbh5$pfb$1(a)fred.mathworks.com...
>
> This may help.
>
> l=figure;
> x = [1 2 3 4 5];
> y = [1 2 3 4 5];
> z = [1 2 3 4 5];
> plot3(x,y,z,'o')
> datacursormode on
> dcmObj = datacursormode(l);
> loop = 1
> while loop == 1
>
> waitforbuttonpress;
> point1 = getCursorInfo(dcmObj);
> x1 = point1.Position(1)
> y1 = point1.Position(2)
> z1 = point1.Position(3)
> end
>
> On encountering waitforbuttonpress. I press the mouse however it then
> continues the code and point1 = 0 because i have not yet selected the
> point as it does not let me. Is there another way instead of
> waitforbuttonpress. i have tried to preassign Point1 but it loses the
> information when it goes into waitforbuttonpress function.

From the looks of your application, you don't want to use a datacursor but
instead you want to use GINPUT.

But if your object is a 2-D representation of a 3-D object, when you click
on the screen the "point" on which you click may be the image of multiple
different points on the object. For example, take a transparent glass and
look at it from the side. Now "click" on a point on the glass. How is the
program supposed to know whether you intended to "click" on the side of the
glass closest to you or the point on the other side of the glass that makes
a straight line with your eye and the nearer intersection point?

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Jane on

Hi,

Can you please explain how to use Ginput to obtain coordinates from the 2d screen and output them to a matrix. I have tried datacursor. I believe you are right regarding how the system knows which is the front and the back but when I tested it using surfaces it wont let me pick the back only what is visible, i think!! This is great help thanks.

Jane
From: Jane on

Hi,

Can you please explain how to use Ginput to obtain coordinates from the 2d screen and output them to a matrix. I have tried datacursor. I believe you are right regarding how the system knows which is the front and the back but when I tested it using surfaces it wont let me pick the back only what is visible, i think!! This is great help thanks.

Jane
From: Jane on

Sorry for the double post. I ask this because I have read the help regarding Ginput and it only talks about selecting specific points on the screen and not picking points which are already there???
From: TideMan on
On Feb 10, 10:53 am, "Jane " <J...(a)mytrashmail.com> wrote:
> Sorry for the double post. I ask this because I have read the help regarding Ginput and it only talks about selecting specific points on the screen and not picking points which are already there???

I reckon that what you're trying to do cannot be done.
plot3 does not produce a 3D plot, but the projection of the 3D plot
onto your 2D screen.
So when you try to use ginput, you are getting the projection, not the
actual data.

IMHO, your only hope is to plot your shape using contour or contourf.
Now, you have a 2D shape, so you can find the x,y position using
ginput and the corresponding z value by interpolation of the surface.