Plot a point in a GUI with mouse click
Afficher commentaires plus anciens
I would like to draw a point in the UIAxes. To do this, I want to determine the position of the mouse pointer in the callback function and draw a point with it. I have created this class:
classdef PlottingClass < handle
properties
fig;
ax;
points = [];
end
methods
function self = PlottingClass();
self.fig = uifigure("Name","test");
self.ax = uiaxes(self.fig);
grid(self.ax,"on")
xlabel(self.ax,"Time")
ylabel(self.ax,"Value")
self.ax.ButtonDownFcn = @self.plottingfcn;
end
end
methods
function plottingfcn(self,axes,hit)
allPoint = hit.IntersectionPoint;
x= allPoint(1);
y= allPoint(2);
z= allPoint(3);
plot(axes,x,y,"o",MarkerSize=2)
self.points = [self.points , [x;y]]
grid(axes,"on")
xlabel(axes,"Zeit")
ylabel(axes,"Value")
disp("x "+x)
disp("y "+y)
disp("z "+z)
end
end
end
When I create an object and click in the UIAxes, I get this output:
x -0.12607
y 1.2151
z -1
Now I wanted to ask why z = -1.
I hope you can help me.
Thank you very much.
Réponse acceptée
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!