how to run iterations?

118 次查看(过去 30 天)
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
z=2;
for K = 1 : 100
z=1+z
end

更多回答(1 个)

Elvin
Elvin 2014-2-6
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)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by