Why ' gpos.m' is not working( ginput with posiiton of the current axes)?

gpos.m file should work like GINPUT provided by Matlab,but it traces the position of cursor without click and is designed for 2-D axes. But Its getting error using in app designer?
Error:
Error using gpos
Too many input arguments.
Can any one help me with this?

3 commentaires

How are you invoking gpos ?
One of the first lines,
h_figure=gcf;
should instead be
h_figure = ancestor(h_axes, 'figure');
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
This page is now archived on the Wayback Machine. Unfortunatly, the attached file could not be recovered.
(Answers Dev) Restored edit

Connectez-vous pour commenter.

 Réponse acceptée

Change
app.tfig = [app.tfig, figure('Name', 'points','WindowButtonMotionFcn',@gpos)];
to
app.tfig = [app.tfig, figure('Name', 'points','WindowButtonMotionFcn',@(src,event)gpos(ancestor(src,'axes')))];

3 commentaires

by changing this
app.tfig = [app.tfig, figure('Name', 'points','WindowButtonMotionFcn',@(src,event)gpos(ancestor(src,'axes')))];
in 'app1.mlapp',
I am getting this error.
Error:
Error in gpos (line 32)
width_axes_unitfig = pos_axes_unitfig(3);
Error in app1>@(src,event)gpos(ancestor(src,'axes')) (line 26)
app.tfig = [app.tfig, figure('Name', 'points','WindowButtonMotionFcn',@(src,event)gpos(ancestor(src,'axes')))];
and I have changed
h_figure = ancestor(h_axes, 'figure'); in gpos.m file as well. I don't know why I am getting like this.
this will work for ginput() and position as well?
I am unclear on the goal here.
Is the goal to be able to have gpos work on uiaxes (which would be in uifigure) ?
Is the goal to be able to have gpos work on traditional axes inside uifigure ?
Is the goal to be able to have gpos work on traditional axes inside traditional figures that just happen to be dynamically created inside App Designer ?
I started converting your code to use uifigure under the assumption that you would want to use gpos with (static) axes created by App Designer, but I gave up at the point where it told me that subplot() could not be used inside that kind of containers that have "automatically resize children" configured.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Exploration dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by