Here is my code:(adsbygoogle = window.adsbygoogle || []).push({});

For this code, the 'while' loop should stop when 'a' reaches 3, however it does not, even though 'a' starts with a higher value than 3.Code (Text):while a ~= 3 || b <= 1;

a = a - 1;

(other expressions);

end;

The 'other expressions' part are calculations that manipulate 'b', the only time I manipulate 'a' is at the first line of the loop. So, it should still work due to the 'OR' condition imposed by the '||' symbol. What could be wrong?

I tried removing the second condition and it works, but I cannot remove it here because it is essential to my calculations.

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab What is wrong with this WHILE loop?

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads - wrong WHILE loop | Date |
---|---|

Mathematica While Loop in Mathematica | Feb 25, 2018 |

Getting wrong answer using Maple (Physics package) | Aug 4, 2015 |

X-Axis is wrong | Sep 22, 2014 |

Mathematica plots wrong | Jun 30, 2014 |

What is wrong in this Latex code? | Jun 5, 2013 |

**Physics Forums - The Fusion of Science and Community**