matlab_introduction_2_17

matlab_introduction_2_17 - EML 2920 Spring 2011 MATLAB...

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

View Full Document Right Arrow Icon
EML 2920 Spring 2011 MATLAB introduction Tony Schmitz Associate Professor Mechanical and Aerospace Engineering
Background image of page 1

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

View Full DocumentRight Arrow Icon
Outline • Examine basic commands typed at the command prompt •Arrays • Equations • Polynomials • Plotting • Systems of equations • M-files Decision-making • Loops • Polynomial fitting
Background image of page 2
Decision-making The usefulness of computer programs is increased by using decision-making functions. This enables operations to be completed that depend on the results of calculations. The relational operators make comparisons between arrays. The result of using relational operators is 1 if true and 0 if false. Not equal to ~= Equal to == Greater than or equal to >= Greater than > Less than or equal to <= Less than < meaning operator 6 5 > 5 5 >= 5 5 = ~ False = 0 True = 1 False = 0 Can compare arrays in element-by- element fashion. Consider examples…
Background image of page 3

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

View Full DocumentRight Arrow Icon
The logical operators also make comparisons between arrays. The result of using logical operators is again 1 if true and 0 if false. Decision-making “A|B” returns an array the same dimensions as “A” and “B”; the new array has ones where either “A” and “B” have nonzero elements and zeros where both “A” or “B” is zero OR | and “B”; the new array has ones where both “A” and “B” have nonzero elements and zeros where either “A” or “B” is zero AND “~A” returns an array with the same dimensions as “A”; the new array has ones where “A” is zero and zeros where “A” is nonzero NOT ~ definition name operator Look at some examples in MATLAB…
Background image of page 4
Decision-making z = ~x = ~[0 3 9] ~x(1) = ~0 = 1 ~x(3) = ~9 = 0 “~A” returns an array with the same dimensions as “A”; the new array has ones where “A” is zero and zeros where “A” is nonzero NOT
Background image of page 5

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

View Full DocumentRight Arrow Icon
Decision-making z = ~x > y = ~[0 3 9] > [14 -2 9] ~x = ~[0 3 9] = [1 0 0] z = [1 0 0] > [14 -2 9] 1 > 14, false = 0 0 > -2, true = 1 NOT
Background image of page 6
Decision-making z = ~(x > y) = ~([0 3 9] > [14 -2 9]) [0 3 9] > [14 -2 9] [0>14 3>-2 9>9] [0 1 0] ~[0 1 0] NOT
Background image of page 7

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

View Full DocumentRight Arrow Icon
Decision-making AND “A&B” returns an array the same dimensions as “A” and “B”; the new array has ones where both “A” and “B” have nonzero elements and zeros where either “A” or “B” is zero z = 2 & 3 = 1
Background image of page 8
Decision-making AND “z” has same dimensions as “x” and “y”
Background image of page 9

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

View Full DocumentRight Arrow Icon
Decision-making “x” dimensions are 1x4 “y” dimensions are 1x5 AND
Background image of page 10
Decision-making OR z = 0 | 3 = 1 “A|B” returns an array the same dimensions as “A” and “B”; the new array has ones where either “A” and “B” have nonzero elements and zeros where both “A” or “B” is zero z = 2 | 3 = 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
Decision-making 5 | 2, true = 1 0 | 5, true = 1 “z” has same dimensions as “x” and “y” 0 | 0, false = 0 OR
Background image of page 12
Results summarized in truth table. F
Background image of page 13

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

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

Page1 / 48

matlab_introduction_2_17 - EML 2920 Spring 2011 MATLAB...

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

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