while loop; a small problem
显示 更早的评论
Dear all,
I have the following statement
k=1;
while abs(k) >= 1
'excecute'
end
the above code is included inside a main loop
I observe though that when k=1; is outside the main loop the algorithm does not get stuck. When I include it inside the main loop after some iterations it gets stuck.
Would it be wrong to put it outiside loop?
thanks
3 个评论
Matt Fig
2012-8-21
What does this do:
'execute'
Jürgen
2012-8-21
And what does the main loop do? It probably influence the value of k in one of both loops...
Jan
2012-8-21
The description "when I include it insie the loop" is clear for you, but not clear for us. Please post the code you are talking about.
回答(1 个)
Matt Fig
2012-8-21
0 个投票
This loop, as you written it, should always 'get stuck' because k does not change inside the loop. What are you trying to do with this loop? Do you just want to print the word execute to the screen once through the outer loop?
类别
在 帮助中心 和 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!