{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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  MATLAB == 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  MATLAB == 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  MATLAB == 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 | Logical OR xor( )
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern