get the location of points in a plot by mouse interaction in app designer

3 visualizaciones (últimos 30 días)
Roberto
Roberto el 10 de Dic. de 2019
Editada: Adam Danz el 17 de Dic. de 2019
I want to get the coordinate of each point in a plot made in app designer. When I click on the plot, a small box shows up and shows the X, Y and Z values of the point. Is there anyway that I can assign these values to a variable in app designer. I know many people asked this question before and I am aware of displaying graphic limitations of app designer; however, I have the hope that someone suggests a creative solution for this problem.
  1 comentario
Roberto
Roberto el 10 de Dic. de 2019
I found this answer to be very useful. The only missing part is how we can show the values of "coordinateSelected" in the interface. for instance:
app.Label.Text=[num2str(coordinateSelected(1,1)),num2str(coordinateSelected(1,1))]

Iniciar sesión para comentar.

Respuestas (1)

Adam Danz
Adam Danz el 10 de Dic. de 2019
Editada: Adam Danz el 17 de Dic. de 2019
That call back function in that answer uses fprintf() to display the results in the command window. To display the results as text in a textbox, simply replace fprintf() with sprintf().
txt = sprintf('[x,y,z] = [%.5f, %.5f, %.5f]', coordinateSelected);
app.Label.Text = txt; % assign char array to text box
If you only want the values
txt = sprintf('%.5f, %.5f, %.5f', coordinateSelected);
app.Label.Text = txt; % assign char array to text box
Both of these examples use 5 decimals of precision which you can adjust as needed.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by