필터 지우기
필터 지우기

My line plot is not showing

조회 수: 3 (최근 30일)
JAmyl Andino
JAmyl Andino 2021년 10월 18일
댓글: JAmyl Andino 2021년 10월 18일
I have a for loop with all its values that i want to plot but the graph shows up and the line doesn't (below for evaluation):
for i=1:Ns
t(i) = Tt2m/Tt_1;
p(i) = (t(i)^((G*e_c)/(G-1)));
Tt1= Tt2;
Tt2 = Tt2 + DT_t;
end
plot (1:Ns,p(i))

채택된 답변

Dave B
Dave B 2021년 10월 18일
편집: Dave B 2021년 10월 18일
Did you want to plot 1:Ns vs p (without the i)?
plot(1:Ns,p)
  댓글 수: 3
Dave B
Dave B 2021년 10월 18일
편집: Dave B 2021년 10월 18일
plot tries hard to match up the lengths of x and y, so plot(1:Ns, p(i)) is interpreted as plotting several line objects:
plot(1:10,1)
Looks like it plots nothing, but that's because MATLAB is plotting several lines with no length. You can see this if you add a marker:
plot(1:10,1,'o')
Note that they have separate colors, that's because they're separate line objects. This is particularly useful in cases where you have several series:
plot(1:100,randn(3,100))
If you drop the (i) I suspect you'll get the behavior you expect. If you just want to plot that last value (i.e. with the i) then maybe add a marker? But I'm not sure that would be a very useful plot...
JAmyl Andino
JAmyl Andino 2021년 10월 18일
Thanks for your help!

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by