Why isn't my graph plotting?

조회 수: 9 (최근 30일)
Anna Byrnes
Anna Byrnes 2021년 8월 8일
댓글: Star Strider 2021년 8월 8일
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!

채택된 답변

Star Strider
Star Strider 2021년 8월 8일
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
Anna Byrnes
Anna Byrnes 2021년 8월 8일
Thanks so much!
Star Strider
Star Strider 2021년 8월 8일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by