For Loop Increment Value
51 次查看(过去 30 天)
显示 更早的评论
I am beginner in MATLAB. I want to write a for loop where the increment value should increase by 2.
For eg:
for i = 1:9
something
end
The value of i should be 1, 3, 5, 7, 9. Kindly help.
0 个评论
采纳的回答
Geoff Hayes
2017-2-11
Just do
for k=1:2:9
% do something
end
where we have defined the step size to be two.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 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!