How can I use the text and sprintf functions to label a point on a graph?

45 vues (au cours des 30 derniers jours)
Andy
Andy le 25 Oct 2014
Commenté : Star Strider le 25 Oct 2014
I need to label a point with its coordinates (x = 5/6, y = 6/9) correct to 4 decimal places. The line y consists of one plot, hence the (x, y, str). When I try the following code no label appears on my graph.
x = 5/7:5/7;
y = % equation of line
plot(x, y);
str = sprintf('%0.4', 5/7, 6/9);
text(x, y, str);

Réponse acceptée

Star Strider
Star Strider le 25 Oct 2014
Try this:
text(5/7, 6/9, str);
  4 commentaires
Andy
Andy le 25 Oct 2014
Whoops. I added the 'f', works now. Thank you very much
Star Strider
Star Strider le 25 Oct 2014
My pleasure!
It happens to us all...

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by