Why isn't my graph plotting?

9 visualizaciones (últimos 30 días)
Anna Byrnes
Anna Byrnes el 8 de Ag. de 2021
Comentada: Star Strider el 8 de Ag. de 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!

Respuesta aceptada

Star Strider
Star Strider el 8 de Ag. de 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 comentarios
Anna Byrnes
Anna Byrnes el 8 de Ag. de 2021
Thanks so much!
Star Strider
Star Strider el 8 de Ag. de 2021
As always, my pleasure!
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by