19 - MATLAB Programming II - Full

19 - MATLAB Programming II - Full - Engineering101

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style Engineering 101 MATLAB Programming II
Background image of page 1

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

View Full DocumentRight Arrow Icon
Quote of the Day - Dorothy Parker   The cure for boredom is curiosity. There is no cure for  curiosity.
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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') 
Background image of page 4
Example: Vector Equality n Suppose x and y are vectors of  the same length if not(x == y)    disp('vectors are not  equal') else
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
.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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online