Control structures are statements in a computer program which alter the order of executed commands. Up to this point, we have written scripts where our computer starts on line 1 to execute commands from left to right, then moves to line 2, then line 3, and so on, in a sequential order. However, this doesn’t always have to be the case.

 

As a programmer, there are several reasons why it would be helpful to be able to control and change this order of execution. First, if we want our computer to perform the same task many times, then we should be able to tell it to repeat certain commands. This concept in programming is called a loop.

 

Second, if we want our computer to perform a task under certain conditions, then we should be able to tell it to test and respond to criteria. This concept in programming is called a conditional statement.

 

Third, if we want to organize and construct a single piece of code to perform a specific task, then we should be able to write reusable scripts. This concept in programming is called a functionIn addition to the built-in functions for Matlab, a programmer has the ability to create their own functions which behave in their own, customizable way.

 

 

Receive Updates

No spam guarantee.