{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Exam 3 Review

# Break will cause the program to immediately exit the

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

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 MATLAB...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online