Borrar filtros
Borrar filtros

How to use this CurrentPoint property?

12 visualizaciones (últimos 30 días)
Saurav Karmakar
Saurav Karmakar el 19 de Abr. de 2020
Comentada: Ameer Hamza el 19 de Abr. de 2020
How to create a program that creates an axes object and that plots a line connecting the locations of successive mouse clicks within the axes. Using the waitforbuttonpress function to wait for mouse clicks and update the plot after each click. Terminate the plot when a keyboard press occurs.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 19 de Abr. de 2020
Editada: Ameer Hamza el 19 de Abr. de 2020
Run this example
f = figure(); % create figure and get its handle
ax = axes(); % create axes and get its handle
xlim([0 1]); % set limits of axes
ylim([0 1]);
hold on; % hold the axes so that the xlim and ylim does not change.
l = line(0, 0); % create an empty line
l.XData = [];
l.YData = [];
while waitforbuttonpress == 0
point = ax.CurrentPoint(1, 1:2); % get coordinate of current point
l.XData = [l.XData point(1)]; % add the current point to the line l
l.YData = [l.YData point(2)];
end
  2 comentarios
Saurav Karmakar
Saurav Karmakar el 19 de Abr. de 2020
Can you explain the steps @Ameer Hamza?
Ameer Hamza
Ameer Hamza el 19 de Abr. de 2020
Saurav, I have added comments with the code.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by