Please I need help with iterations. For instance, if my Matlab script runs thus:
z=2; z=1+z
What can i do if i am looking to run this a hundred times such that the result from '1+z' is put in place of Z upon every iteration. Thanks

 채택된 답변

Walter Roberson
Walter Roberson 2014년 2월 6일

1 개 추천

z=2;
for K = 1 : 100
z=1+z
end

추가 답변 (1개)

Elvin
Elvin 2014년 2월 6일

1 개 추천

You can try something like this:
z = 0;
for i = 1:100
z = z+i;
end

댓글 수: 2

Walter Roberson
Walter Roberson 2014년 2월 6일
Notice this is "z+i" (lower-case I) not "z+1" (digit one)
Oluyemi Jegede
Oluyemi Jegede 2014년 2월 6일
thanks

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

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by