{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

18 - MATLAB Programming I - Full

18 - MATLAB Programming I - Full - Engineering101...

Info icon This 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
Image of page 1

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

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

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

View Full Document Right 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
Image of page 4
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
Image of page 5

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

View Full Document Right Arrow Icon
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.
Image of page 6
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
Image of page 7

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

View Full Document Right Arrow Icon
Conditional Operators n Conditional operators can be used between  arrays 1 5 > 3 1 3 -1 -1 2
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
Image of page 9

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

View Full Document Right 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
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
Image of page 11

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

View Full Document Right Arrow Icon
Logical Operators in MATLAB & Logical AND | Logical OR xor( )
Image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern