Skip to main content
Logo image

Section 2.4 Conditional Gates

So far, we’ve written code that runs step by step in a straight line. Real programs need to react to data or user input, choosing different actions when conditions change. This kind of decision-making is called flow control. In MATLAB, if-statements and switch-statements let you test conditions and choose the path your code follows.