How can I plot graph in this relationship?
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm trying to plot graph of relations of (j,s) in this for script.
s=0;
for j=1:1:10
s=s+j;
disp(['j = ', num2str(j)] );
disp(['s = ', num2str(s)] );
plot(j,s)
end
however, nothing appears when I try to plot it. What's the problem with it? And how can I plot graph of the relationship between (j,s)?
댓글 수: 0
채택된 답변
Torsten
2023년 10월 31일
편집: Torsten
2023년 10월 31일
s=0;
hold on
for j=1:1:10
s=s+j;
disp(['j = ', num2str(j)] );
disp(['s = ', num2str(s)] );
plot(j,s,'b o')
end
hold off
댓글 수: 1
Torsten
2023년 10월 31일
It's more common to compute all values for s in advance and make the plot afterwards:
x = 1:10;
s = cumsum(x);
plot(x,s,'b o')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!