Basic loop syntax in MATLAB: for k=1:n

回答(2 个)

it means that everything between that line
k = 1:n
and
end
will be evaluated with k = every integer between 1 and n.
doc for
for more information
(Adjusting Sean's answer):
it means that everything between that line
k = 1:n
and
end
will be evaluated with k = every integer starting at 1 and not exceeding n; no iterations will be done at all if n < 1
doc for
for more information

4 个评论

Jan
Jan 2011-1-28
编辑:Jan 2017-12-30
If you think Walter's adjustments are peantus, read: http://www.mathworks.com/matlabcentral/newsreader/view_thread/293533
Heh. Somehow I missed that discussion the first time around!
Jan, how do you remember these things! There are obviously no angry armadillos bouncing around in your head.

请先登录,再进行评论。

类别

帮助中心File 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