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.

采纳的回答

Geoff Hayes
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 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