This preview shows page 1. Sign up to view the full content.
Unformatted text preview: mediately exit the loop continue will cause the program to skip to the end of the loop, but the loop will continue to iterate if it is not complete. Selection on Logic Vectors
What does the following do, if x is an array (and, therefore, the condition expression is an array of bools)? bools)? if x > 20 disp('condition disp('condition is true') else disp('condition disp('condition is false') The "condition is true" iff the condition holds for all elts of x, otherwise the "condition is false" 7 Example: Vector Equality
Suppose x and y are vectors of the same length
if not(all(x == y)) disp('vectors disp('vectors are not equal') else disp('vectors disp('vectors are equal') This works as intended because: all(A): Returns true if all elements in A are true Returns false if any elements in A are false Nested Functions
Unlike subfunctions, nested functions share the subfunctions, scope of their nesting function:
They can access and modify variables in the nesting function's scope Variables introduced in the nested function are accessible within the nesting function's scope The formal parameters (input and output) of the nested function are not accessible to the nesting function Nested Functions
A function can call its nested functions A nested function can call its nesting function (recursion), as well as any functions its nesting function can call All nesting and nested functions must finish with the end statement Default Arguments in Functions
View Full Document
This note was uploaded on 05/04/2010 for the course ENGIN 101 taught by Professor Jeffringenberg during the Spring '07 term at University of Michigan.
- Spring '07