Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

help for while loop

$
0
0
I have a very simple while loop, which was supposed to break right away until n = 10. But this loop never break because n = 10.1 in the end. How could this happened?

n = 0;
flag = 0;
while (flag == 0)
if( n < 10)
    n = n + 0.1;
   if(n == 10)
    flag = 1;
   end
end
end

Viewing all articles
Browse latest Browse all 19628

Trending Articles