18 - MATLAB Programming I - Full

# 18 - MATLAB Programming I - Full - Engineering101

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

Click to edit Master subtitle style Engineering 101 MATLAB Programming I

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

View Full Document
Quote of the Day - Confucius Those who will not economize will have to  agonize.
Programming in MATLAB n Just as in C++ we must have at our disposal: n Sequence n Iteration n Selection

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

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

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

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

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

View Full Document
Conditional Operators n Conditional operators can be used between  arrays 1 5 > 3 1 3 -1 -1 2
Conditional Operators n Conditional operators can be used between  arrays 1 5 > 3 1 0 1 3 -1 -1 2 1 0

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

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

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

View Full Document
Logical Operators in MATLAB Logical AND
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
Ask a homework question - tutors are online