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

Re: While loop with & condition

$
0
0
On 8/24/2013 9:26 AM, Michael wrote:

>
> > > while d1_err > tol & d2_err > tol
> ...
> > > end
....
> No, what is happening is that once d2_err < tol, the while loop stops. What i'm
>trying to do is make the while loop continue until they are BOTH below the tolerance (tol).

First of all, why are you using & instead of && here? These are scalar
values, then && is the more approrpiate operator.

Second, you need to do

    while (d1_err > tol || d2_err>tol)
    ....

or

    while ~(d1_err < tol && d2_err < tol)
    ....


--Nasser

Viewing all articles
Browse latest Browse all 19628

Trending Articles