Interactive Plot that returns a value

Hello,
I wanted to know how to create a "interactive" plot in matlab in which the program pauses while the graph is displayed and user has to select a certain value in the graph, then the program continues execution with the value chosen by the user.

 Respuesta aceptada

Adam Danz
Adam Danz el 9 de Mzo. de 2020

1 voto

Check out ginput() and let us know if you have any quesitons or problems.

4 comentarios

Harish Rajan
Harish Rajan el 9 de Mzo. de 2020
is it possible to get the array index of the chosen variable instead of the actual x and y coordinates ?
Adam Danz
Adam Danz el 9 de Mzo. de 2020
Editada: Adam Danz el 9 de Mzo. de 2020
Yes, with a little bit of code.
Presumably you have the (x,y) coordinates of each point. Use pdist2() to compute the distance of each point from the selected coordinate. The point you selected is the one with the minimum distance.
Note that if your points are tightly clustered you may run into precision issues.
If you have any problems, share the relevant parts of the code and I'd be glad to help you out.
Harish Rajan
Harish Rajan el 9 de Mzo. de 2020
Thank you, i will try this solution !
Adam Danz
Adam Danz el 9 de Mzo. de 2020
Ok, i'll be here if you get stuck.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Networks en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Etiquetas

Preguntada:

el 9 de Mzo. de 2020

Comentada:

el 9 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by