For Loop Increment Value

47 ビュー (過去 30 日間)
HARSHVARDHAN SARAVANAKUMAR
HARSHVARDHAN SARAVANAKUMAR 2017 年 2 月 11 日
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.
  1 件のコメント
HARSHVARDHAN SARAVANAKUMAR
HARSHVARDHAN SARAVANAKUMAR 2017 年 2 月 11 日
Thank you. I feel silly. This was easy.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by