MATLAB has two loop control techniques
- Counted loops - executes commands a specified number of times.
- Conditional loops - executes commands as long as a specified expression is true.
The while- loop used when the number of loop iterations is unknown. Number of iteration is controlled by a condition. The condition is tested in each iteration and stop looping when it is false. While loop will execute the body of loop ONLY if while condition is met.
Both Scripts and functions also allow to loop using for and while loops.