Guys, this seems very simple and trivial, but I'm having a great amount of difficult with this
I have this for loop below, how can I write it in the while form?
for k=1:3:9
x=k^2
end

 採用された回答

per isakson
per isakson 2015 年 5 月 31 日
編集済み: per isakson 2015 年 5 月 31 日

0 投票

Something like this might do it
k = 1;
while k <= 9
x = k^2
k = k+3;
end

1 件のコメント

Daniel Garutti
Daniel Garutti 2015 年 5 月 31 日
thank you sir! It worked like a charm

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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