How to write this for loop into while loop?

1 次查看(过去 30 天)
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
Something like this might do it
k = 1;
while k <= 9
x = k^2
k = k+3;
end

更多回答(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