How do I collect values that were done through the loop?
For example,
M=10:40
for i=0:30;
i=i+1;
A=10+M(i);
end
and the answer just comes out as A=50, instead of A=20:50. What would I do in order to collect the 30 values as matrix?

 채택된 답변

Andrejus
Andrejus 2014년 10월 19일
편집: Andrejus 2014년 10월 19일

0 개 추천

try this:
M=10:40
for i=0:30;
i=i+1;
A(i)=10+M(i);
end

댓글 수: 1

Jan
Jan 2014년 10월 19일
Do not increase the value of the loop copunter inside loop.

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

추가 답변 (1개)

Jan
Jan 2014년 10월 19일

0 개 추천

M = 10:40
A = M + 10;

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

JK
2014년 10월 19일

답변:

Jan
2014년 10월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by