Plot inside a for loop
이전 댓글 표시
hi all, I need your help. I am trying to plot a graph inside a for loop but only dots is appearing on the plot. the dots are not link with each other here is my code:
how can I make a clear line graph with all the dots joined. Help me please its urgent!!!
댓글 수: 1
Walter Roberson
2012년 4월 2일
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
채택된 답변
추가 답변 (1개)
saima
2012년 3월 31일
0 개 추천
because each time loop runs your value of x and y becomes a scaler. try to use other variable than x and try to accumulate the values and then use the plot outside the loop
댓글 수: 2
saima
2012년 3월 31일
can help you elaborately if you explain your code in a little detail
Kostas
2012년 3월 31일
try something like this
k=0; %initialize k
for x = 0:250
.
k=k+1 %raise k value +1 in each iteration
a(k) = x * ....;
b(k) = x * ....;
.
y(k) = a + b; % accumulate all values to the vector y, has the same size like x vector
end
x=x(:);
plot(x,y) %x and y are vectors
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!