From: Nicky on

Dear all,

I am having troubles obtaining coordinates from the axis automatically and inserting them into a matrix. I have read that there are two functions that access the input of the screen? Namely ginput and datacursor.

Problem 1:
The problem is the following. For example. I have a 3D cube. The cube therefore has 8 known Points that have already been drawn in matlab's axis. I used datacursor in conjuction with wait for mouse input to select these known points. However the wait for mouse input requires a Press of its own and the datacursor also requires another press with the mouse but on the first press the code runs and thus leaving 0 in the array matrix and not the coordinate information.

Problem 2:
Assuming the first problem is solved. I would like to be able to select any point along the front surface of the cube. what if the shape is not a cube? what if it is sphere? how can we select points along this surface?

Comments
I do not know how to use ginput for xyz information. Maybe someone can enlighten me. I am assuming that data cursor cannot solve problem 2. Is this a limitation of matlab or is there any possiblity to program this. Regarding problem 1. I have managed to obtain the coordinates a different way by using its update text function but i was not successful in using them within the function of update.

Please any help would be great regarding retreaving coordinate information from input using mouse.

Nick
From: Nicky on

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: Nicky on
following to this i have tried Pause(10) and this lets me select the point in time lol. Not an ideal way but it works.
From: Praveen on
On Feb 7, 8:28 am, "Nicky " <n...(a)mytrashmail.com> wrote:
> following to this i have tried Pause(10) and this lets me select the point in time lol. Not an ideal way but it works.

Try this utility:
http://www.mathworks.com/matlabcentral/fileexchange/13857

HTH,
Praveen
From: Nicky on

Hi,

That application doesn't return Z coordinate?