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

3 visualizzazioni (ultimi 30 giorni)
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 Commento
Roberto
Roberto il 10 Dic 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))]

Accedi per commentare.

Risposte (1)

Adam Danz
Adam Danz il 10 Dic 2019
Modificato: Adam Danz il 17 Dic 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.

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by