matlab_introduction_2_17

matlab_introduction_2_17 - EML 2920 Spring 2011 MATLAB...

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

EML 2920 Spring 2011 MATLAB introduction Tony Schmitz Associate Professor Mechanical and Aerospace Engineering

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

View Full Document
Outline • Examine basic commands typed at the command prompt •Arrays • Equations • Polynomials • Plotting • Systems of equations • M-files Decision-making • Loops • Polynomial fitting
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…

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

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

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

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

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

View Full Document
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
Decision-making AND “z” has same dimensions as “x” and “y”

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

View Full Document
Decision-making “x” dimensions are 1x4 “y” dimensions are 1x5 AND
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

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

View Full Document
Decision-making 5 | 2, true = 1 0 | 5, true = 1 “z” has same dimensions as “x” and “y” 0 | 0, false = 0 OR
Results summarized in truth table. F

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/06/2011 for the course EML 2920 taught by Professor Carrol during the Spring '09 term at University of Florida.

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
Ask a homework question - tutors are online