From: Marcin on
Hi,

I have a mesh plot with ButtonDownFcn handler. How can I convert the coordinates of a clicked point (CurrentPoint) to data values used to create the mesh?

Many thanks
From: Marcin on
"Marcin " <mb1234(a)gazeta.pl> wrote in message <huipvo$i5l$1(a)fred.mathworks.com>...
> Hi,
>
> I have a mesh plot with ButtonDownFcn handler. How can I convert the coordinates of a clicked point (CurrentPoint) to data values used to create the mesh?
>
> Many thanks

Once again answering my own question - maybe it will be useful to someone:

function [pout, vout, viout, pfactor, facevout, faceiout] = vertexpicker(varargin)
% This internal helper function may change in a future release.

% [P V I PFACTOR] = VERTEXPICKER(OBJ,TARGET,MODE)
% OBJ is an axes child.
% TARGET is an axes ray as if produced by the 'CurrentPoint' axes
% property.
% MODE is optional, '-force' will find closest vertex even if the
% TARGET ray does not intersect OBJ. This option is used by
% the data cursor feature as the mouse drags away from the
% object
%
% P is the projected mouse position on OBJ.
% V is the nearest vertex to P.
% I is the index to V.
% PFACTOR is the amount of interpolation between P and V.
%
% [P V I PFACTOR] = VERTEXPICKER(OBJ,MODE) Assumes TARGET
% is the axes current point