how to plot points in a loop?
조회 수: 10 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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,'-*')
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!