how to plot points in a loop?

조회 수: 10 (최근 30일)
Chen Ji
Chen Ji 2018년 3월 1일
댓글: Austin Selvog 2020년 10월 29일
for x=1:10
a=2*x
b=3*x^2
plot(a,b)
end
But the figure cannot be plotted. What should i write for the codes?
  댓글 수: 1
Stephen23
Stephen23 2018년 3월 1일
@Chen Ji: do you want the points to be joined by a line?

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

답변 (1개)

Stephen23
Stephen23 2018년 3월 1일
편집: Stephen23 2018년 3월 1일
figure()
hold on
for ...
...
plot(a,b,'*')
end
But I would not recommend doing this: the simpler MATLAB solution would be to write vectorized code:
X = 1:10;
A = 2*X;
B = 3*X.^2;
plot(A,B,'-*')
  댓글 수: 1
Austin Selvog
Austin Selvog 2020년 10월 29일
This also does not work

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

카테고리

Help CenterFile Exchange에서 Frequency-Domain Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by