File Exchange

image thumbnail

Mouse Position

version 1.0 (2.95 KB) by

get mouse position within an axes.



View License

%This function works with subplots as well as individual axes in one figure
%or multiple figure,
%it requires handle to figure object that the functionality need to be
%associated with.
%multiple figure handles can be passed to it. it then finds the axes
%automatically if there are any. it returns with no error otherwise if it
%can not find at least one axes object in a vector of figure/s supplied to
%it can be set off, if varargin{2}='' or [] or {} or 'off'.
%if nargin = 1 then it asigns the functionality with all the figure/s
%supplied to it.

Comments and Ratings (12)



hey Jong:

doing it for a 3D case should not be a problem i think, although i have not found anything on websites for it...however i think i would like to do something like that and i will in soon future. thanks for the rating and comment.

Jong-Hwan Kim

Jong-Hwan Kim (view profile)

Can you make 3D output. For instance, I have 3D figure. When I put mouse point at plot, it shows x, y, and z position as well.


peter (view profile)

thanks, will do that


peter (view profile)

peter, i just checked the function in matlab 2010a and it is fine if you remove narginchk, good luck.

yea that might be why, i just used help narginchk in matlab 010, same thing happened to me! i wrote this function using R2011b, however this is not important just get rid of it as the rest of the function checks for required inputs to be handles, figures, checks to see if a second input exists and if it is what it expects. if you are happy with the rest of the function then, removing narginchk won't change anything at all.


peter (view profile)

help narginchk

narginchk not found.

Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.

I am using Matlab 2010a.

matlab's function, peter. help narginchk.


peter (view profile)

thanks, is this "narginchk" your own function ? or Matlab's function ?

peter, i do not know why you get that, all narginchk(1, 2) does is to check that user has supplied a minimum of 1 and a maximum of 2 arguments. that is it. check this on matlab help doc. however this is not important and you can comment it and get rid of it. make sure you give the right number of inputs to the function if you do. works fine on my system.


peter (view profile)

??? Undefined function or method 'narginchk' for input arguments
of type 'double'.

Error in ==> GetMousePosition at 32
narginchk(1, 2),

Error in ==> test_GetMousePosition at 26
GetMousePosition([f1, f2, f3, f4, f5, f6], 'on')

MATLAB Release
MATLAB 7.13 (R2011b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today