Figure 8: Overview of Matlab code (flow chart).