Do while loop in Matlab
1,612 views (last 30 days)
Mischa Kim on 9 Feb 2014
Edited: MathWorks Support Team on 27 Nov 2018
There is no 1-to-1 correspondence to the C++ do while loop in MATLAB. Your best option is to use a while loop. The difference is that while loops check the condition at the beginning of the loop while do while loops check the condition at the end of the loop.
while (abs(A-B) <= 50)
To check the condition at the end of the loop using a while loop, use an if statement inside the while loop:
if ~(abs(A - B) <= 50)