ABSTRACT

Now that the loop is initiated, it is important to define the information within it. You should always indent information within loops so it is easy to recognise and understand visually (one indent is four spaces). MATLAB will normally do this automatically, but double-check that it works and ensure that it is consistent throughout the script. You can also highlight any block of code that you want to indent in one go, and click the ‘Indent’ button in the ‘Edit’ panel of script editor window (if you hover over the button it should tell you what the keyboard shortcut is: for Macs, cmd + ] should do the job, and ctrl + ] should work for Windows). Now let’s go back to the for loop we started and start entering some instructions in Figure 4.1.