Plot function is not working

조회 수: 7 (최근 30일)
Juan Pablo  Arango
Juan Pablo Arango 2019년 10월 7일
댓글: Juan Pablo Arango 2019년 10월 7일
I'm having problem plotting some function from my homework assignment. I created a code similar in structure to what I am trying to do. Same problem, the graph is not showing. Do you guys have any clue what to do here?
The code is given as follows:
n = 1;
h = 0.05;
t(n) = 0;
y(n) = 0;
while t(n)+h < 8
y(n+1) = pi^(-n^2);
t(n+1) = t(n) + h;
n = n + 1;
end
plot(t(n),y(n))

채택된 답변

the cyclist
the cyclist 2019년 10월 7일
편집: the cyclist 2019년 10월 7일
Your plotting code is trying to select just one element from the t and y vectors.
I think you want this instead:
plot(t,y)
(I changed my answer a bit after your edit.)
  댓글 수: 2
Juan Pablo  Arango
Juan Pablo Arango 2019년 10월 7일
Thank you so much! I will try it now!
Juan Pablo  Arango
Juan Pablo Arango 2019년 10월 7일
I tried with homework question that had similar problem, and it worked! Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by