MATLAB: Conditional statements and while loop

while loop

Hi,
I have the following while loop
while (dif1 > tol) && (dif2 > tol) && (dif3 > tol)
procedure
end
I want all the conditions to be simultaneously satisfied. However, when I execute the code, the second condition dif2 > tol is not satisfied although the algorithm stops.
what I am doing wrong here ?

Best Answer

while (dif1 > tol) || (dif2 > tol) || (dif3 > tol)
should work if you want to carry on until all are false.