Loops are used when you need to repeat a set of instructions multiple times.
Two type of loops; for loops and while loops
How to choose:
for loops if you know how many times you need to repeat the loops
while loops if you need to keep repeating the instructions until a criterion is met
The big difference between while and for loops is
MATLAB decides how many times to repeat the loops
While loops continue until the criteria are met
The format is
while criteria
command to be executed
end