How to display the coordinate of the point in the figure

53 views (last 30 days)
T
T on 24 Jan 2016
Answered: Afshin Aghayan on 8 Oct 2019
The problem is similar to this but I have an x-axis that decreases from 1 to 0 at increments of 0.1 https://www.mathworks.com/matlabcentral/answers/89104-how-to-display-the-coordinate-of-the-point-in-the-figure
for k=1:numel(x)
text(x(k),y(k),['(' num2str(x(k)) ',' num2str(y(k)) ')'])
end
I also need to adjust the window for this but axis won't work because it only applies for increases x-values.
Can someone advise me how to accommodate for these changes?

Answers (3)

T
T on 24 Jan 2016
This is the output image of what I'm getting.
You can see the points are not following the curve.

Walter Roberson
Walter Roberson on 24 Jan 2016
The labels are being put into the proper place on the graph. Your third point is at y = -3.something which happens to be outside the range of what you are displaying. That is not the fault of text(), that is because you have told it coordinates that are not on your graph.
  5 Comments
T
T on 25 Jan 2016
The red and green star, what is the purpose of this? It's not a necessary point, I just want to show the 8 points and extrapolate the end of the function as f approaches 0.

Sign in to comment.


Afshin Aghayan
Afshin Aghayan on 8 Oct 2019
you can use this code for displaying any data in the form of [x, y, f(x,y)] or data with coordinate

Tags

Community Treasure Hunt

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

Start Hunting!