19 - MATLAB Programming II - Full

# 19 - MATLAB Programming II - Full - Engineering101...

This preview shows pages 1–10. Sign up to view the full content.

Click to edit Master subtitle style Engineering 101 MATLAB Programming II

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Quote of the Day - Dorothy Parker   The cure for boredom is curiosity. There is no cure for  curiosity.
Selection on Logic Vectors n What does the following do, if x is an array (and,  therefore, the condition expression is an array of  bools)? if x > 20    disp('condition is true') else    disp('condition is false') n The “condition is true” iff the condition holds for

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example: Vector Equality n Suppose x and y are vectors of  the same length if x == y   disp('vectors are equal') else    disp('vectors not equal')
Example: Vector Equality n Suppose x and y are vectors of  the same length if not(x == y)    disp('vectors are not  equal') else

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example: Vector Equality n Suppose x and y are vectors of the  same length if not(all(x == y))    disp('vectors are not  equal') else
.p Files n MATLAB stores function definitions in an  internal format called  pcode n It avoids repeating some interpreter processing  (e.g., parsing text) every time a function is invoked n It’s a form of compilation, but not to a native  machine language n Create pcode with the command: pcode   fn_name

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Nested Function Definitions n You can also define a function  within  another  function definition: function [a, b] = someFunction (x, y) function c = nestOne(z) end nestOne  is a   nested function  of  someFunction someFunction  is the  nesting function  of  nestOne
Nested Functions n Unlike subfunctions, nested functions share  the  scope   of their nesting function: n They can access and modify variables in the  nesting function's scope n Variables introduced in the nested function are  accessible within the nesting function's scope n The formal parameters (input and output) of the  nested function are  not  accessible to the nesting  function

This preview has intentionally blurred sections. Sign up to view the full version.

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

{[ snackBarMessage ]}

### Page1 / 32

19 - MATLAB Programming II - Full - Engineering101...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online