18 - MATLAB Programming I - Full

18 - MATLAB Programming I - Full - Engineering101

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style Engineering 101 MATLAB Programming I
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 - Confucius Those who will not economize will have to  agonize.
Background image of page 2
Programming in MATLAB n Just as in C++ we must have at our disposal: n Sequence n Iteration n Selection
Background image of page 3

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

View Full DocumentRight Arrow Icon
Selection in MATLAB n Three selection constructs: n if n switch/case n try/catch   n To decide if a portion of code will be executed  we need to determine a condition. n This requires conditional operators
Background image of page 4
Conditional Operators in  == equal to ~= not equal to > greater than >= greater than or equal to < less than <= less than or equal to These return 1 for true or 0 for false
Background image of page 5

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

View Full DocumentRight Arrow Icon
Conditional Operators in  == equal to ~= not equal to > greater than >= greater than or equal to < less than <= less than or equal to Be careful with the == operator.  Since all numbers are  doubles small rounding errors can make expressions not  equal.
Background image of page 6
Conditional Operators in  == equal to ~= not equal to > greater than >= greater than or equal to < less than <= less than or equal to For example,  if 0 == sin (pi)  returns  0  because  sin(pi)   returns  1.2246e-016
Background image of page 7

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

View Full DocumentRight Arrow Icon
Conditional Operators n Conditional operators can be used between  arrays 1 5 > 3 1 3 -1 -1 2
Background image of page 8
Conditional Operators n Conditional operators can be used between  arrays 1 5 > 3 1 0 1 3 -1 -1 2 1 0
Background image of page 9

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

View Full DocumentRight Arrow Icon
Conditional Operators n Conditional operators can be used between  arrays 1 5 > 3 1 0 1 3 -1 -1 2 1 0 n They can also be used between a scalar and  an array 5 > 8 2 10 -1
Background image of page 10
Conditional Operators n Conditional operators can be used between  arrays 1 5 > 3 1 0 1 3 -1 -1 2 1 0 n They can also be used between a scalar and  an array 5 > 8 2 0 1 10 -1 0 1
Background image of page 11

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

View Full DocumentRight Arrow Icon
Logical Operators in MATLAB Logical AND
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/07/2010 for the course ENGR engr 101 taught by Professor Rinenberg during the Spring '10 term at University of Michigan.

Page1 / 39

18 - MATLAB Programming I - Full - Engineering101

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online