7: Conditionals Part 2 Series, Switch Logic, and While Loops
- Page ID
- 84330
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
- 7.1: if, elseif, else with Error Checking
- This section gives more if, elseif, else, examples. It also shows how to use the error() function.
- 7.2: Flowcharts
- if, else, elseif, error, flowchart
- 7.3: The input() Function
- input() function and concatenation of strings
- 7.4: Compound Logical Operators
- Compound Logical Operators: and (&), or (|)
- 7.5: Working with Conditions
- Shows how to use conditions to test for valid variable values. Show some things that could go wrong. Shows how to search for values.
- 7.6: Shortcut and, or, Logical Operations
- Shortcut "and" (&&), shortcut "or" (||)
- 7.7: for loops with break Logic
- for loop with if logic and break
- 7.8: 'while' Loops
- While loops are similar to for loops. While loops do not have an automatic increment nor an automatic end. The user has to code those. It it typically for a loop with an unknown number of iterations.
- 7.9: 'switch' Logic
- "switch" logic structure examples and exercises
- 7.10: The find() function
- The MATLAB built-in function find() is an efficient method to find the indices of data that satisfy some logical condition.
.