Why isn't my graph plotting?

7 vues (au cours des 30 derniers jours)
Anna Byrnes
Anna Byrnes le 8 Août 2021
Commenté : Star Strider le 8 Août 2021
This was my input code:
x = [0:0.25:5];
y = exp(x)/(exp(x)-1);
plot(x,y)
And when I run it it just comes up with a blank set of axes with no actual graph on it, not really sure why this is so any help would be appreciated!

Réponse acceptée

Star Strider
Star Strider le 8 Août 2021
That is because using matrix right division (/) it is plotting onlly one point, and while this would work if it also plots markers, will not work to plot lines, that require at least two points in order to draw a line between them.
Using element-wise division (./) creates the necessary vector and draws the plot —
x = [0:0.25:5];
y = exp(x)./(exp(x)-1);
% ↑ ← HERE
plot(x,y)
.
  2 commentaires
Anna Byrnes
Anna Byrnes le 8 Août 2021
Thanks so much!
Star Strider
Star Strider le 8 Août 2021
As always, my pleasure!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by