To save content items to your account,
please confirm that you agree to abide by our usage policies.
If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account.
Find out more about saving content to .
To save content items to your Kindle, first ensure no-reply@cambridge.org
is added to your Approved Personal Document E-mail List under your Personal Document Settings
on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part
of your Kindle email address below.
Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations.
‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi.
‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Chapter 5 introduces perhaps the most difficult tools for new programmers to grasp, namely conditionals and loops, which control when, whether, and how often code executes. Presentation of conditionals and loops begins with descriptions of what they do: conditionals control whether code runs, or which piece of code runs from multiple options; while loops make code run repeatedly, either “while” some condition is met (“while” loops) or “for” each element of a set of values (“for” loops). This presentation makes clear to students how to translate these descriptions into MATLAB code, allowing them to see the correspondences between the broader programming task and the tools that accomplish them. Syntax is explored in detail, including common pitfalls and specification errors. Lastly, syntax for interrupting loops and changing their operation is presented, furthering students’ mastery of these critical tools.
In this chapter the reader creates if statements, which include elif and else statements, and learns about nesting statements together. They become familiar with conditional operators such as greater than, less than and equal to along with comparison operators such as and, or and not as they build upon the knowledge they have acquired in the first chapter to program solutions for the eight given challenges.
Recommend this
Email your librarian or administrator to recommend adding this to your organisation's collection.