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

3 次查看(过去 30 天)
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 个评论
Roberto
Roberto 2019-12-10
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))]

请先登录,再进行评论。

回答(1 个)

Adam Danz
Adam Danz 2019-12-10
编辑:Adam Danz 2019-12-17
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.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by