This blog summarizes the program's flow control in MATLAB for quick reminders.
If...else...end
If (condition 1 == true)
statements 1
elseif (condition 2 == true)
statements 2
elseif (condition 3 == true)
statements 3
else % optional
statements 4
end
for...end
for i=1:any
statements
end
while...end
while (condition == true)
statements
if (condition = true)
break
end
end
switch...otherwise...end
switch x
case 1
statements 1
case 2
statements 2
otherwise
statements 3
end
Table 4.1 shows the conditional operators used in flow control structures.
REFERENCE
MEB Magrab et al., An Engineer's Guide to MATLAB, Prentice Hall, 2000