View License

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

» Watch video

Highlights from
Mouse Position

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.0 | 4 ratings Rate this file 1 Download (last 30 days) File Size: 2.95 KB File ID: #33107 Version: 1.0

Mouse Position



get mouse position within an axes.

| Watch this File

File Information

%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.

MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
21 Dec 2011 sunshine


09 Nov 2011 rasam aliazizi

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.

Comment only
06 Nov 2011 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.

04 Oct 2011 peter

peter (view profile)

04 Oct 2011 peter

peter (view profile)

thanks, will do that

04 Oct 2011 rasam aliazizi

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

Comment only
04 Oct 2011 rasam aliazizi

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.

Comment only
03 Oct 2011 peter

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.

Comment only
03 Oct 2011 rasam aliazizi

matlab's function, peter. help narginchk.

Comment only
03 Oct 2011 peter

peter (view profile)

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

Comment only
03 Oct 2011 rasam aliazizi

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.

Comment only
03 Oct 2011 peter

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')

Comment only

Contact us