How to work with the current point feature in app designer?

Hello,
The below code is working in Matlab but I am unable to execute this same thing in Matlab app designer.
fig = figure('Interruptible', 'off');
ax1 = subplot(1,2,1);
ax2 = subplot(1,2,2);
fig.WindowButtonMotionFcn = @(~,~) [];
t = timer('Period', 0.1, 'ExecutionMode', 'fixedRate', 'TimerFcn', {@mouseMotionCB, ax1, ax2});
start(t)
ginput(1)
stop(t);
delete(t);
function mouseMotionCB(fig, event, ax1, ax2)
currentPoint1 = ax1.CurrentPoint(1,1:3);
x1 = currentPoint1(1);
y1 = currentPoint1(2);
if (ax1.XLim(1)<x1)&&(x1<ax1.XLim(2)) && (ax1.YLim(1)<y1)&&(y1<ax1.YLim(2))
fprintf('This is axes 1, Current Point is %f %f %f\n', currentPoint1);
end
currentPoint2 = ax2.CurrentPoint(1,1:3);
x2 = currentPoint2(1);
y2 = currentPoint2(2);
if (ax2.XLim(1)<x2)&&(x2<ax2.XLim(2)) && (ax2.YLim(1)<y2)&&(y2<ax2.YLim(2))
fprintf('This is axes 2, Current Point is %f %f %f\n', currentPoint2);
end
end
I have created an 'app1.mlapp', but this code is not executing in app designer .Can anyone help me with this?

2 Comments

what is the error you get when running this code in appdesigner?
ginput() is working , after the mouseclick values are printing in workspace.
It not displaying the values at figure window.
Error : Too many input arguments

Sign in to comment.

Answers (1)

Please see the app attached with the script for the callback function. Let me know if this addresses your problem.
Note, I also attached an app for the pop up window if you were interested in using this instead.

6 Comments

Its not display the coordinates when ginput() is working. Here I am enclosing the '.mfile' . The same thing should work in matlab app designer.
Please check the below attachment
And I have another question that, here i am using ginput() to select the points for calculation. Instead of this how to use (x,y) coordinates from editfield to select the graph points?
Is it possible to do that?
Any particular reason you are not using the brush function? (See BrushTest.mlapp attached)
Please see the attached app and script to see the use of an alternative crosshair.
Ok, i will explain you the problem. When we import the data it will plot graphs accordingly. After this, I wanted to cutoff the graphs using ginput(). Please look the 'image1.jpg'. After this only these cutoff plot should plot. In this everything is working, but I wanted to see the y-axis point or else when using ginput(), wanted to use the same Y-axis value, different x-axis value should be used for cutting the axis.
So Here I have two options to do that
  1. ginput() cursor should move with showing the coordinates
  2. For the ginput() is there any possibility to give Y-coordinate using a edit field
Here I am enclosing another file ginputc() which is for me. But it is showing coordinates after the mouse click.
why the above code is not working for me. I am using matlab 2021rb, Is this the reason?
Please help me to fix this issue?
I changed
brush(app.UIAxes,"on")
to
brush(app.UIAxes,'on')
and it worked for me in R2021b (see attached).
Is there a reason crossair.mlapp doesn't work for you?

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Asked:

on 14 Sep 2022

Commented:

on 27 Sep 2022

Community Treasure Hunt

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

Start Hunting!