필터 지우기
필터 지우기

Quick question about the loop

조회 수: 1 (최근 30일)
JK
JK 2014년 10월 19일
답변: Jan 2014년 10월 19일
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일
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일
M = 10:40
A = M + 10;

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by