matlab_introduction_2_10_11

matlab_introduction_2_10_11 - EML 2920 Spring 2011 MATLAB...

Info iconThis preview shows pages 1–11. 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
Command prompt ( ) x cos 5 y = Consider the cosine function: First, define x and then calculate y. Step size in x is: 10 2 π Range is -2 π to 2 π . Trigonometric functions require inputs in radians ( π rad = 180 deg), not degrees, for MATLAB. In this case, it would be better to graph the data to see the result. Use the “plot” function to graph (x, y) data.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Command prompt -6 -4 -2 0 2 4 6 -5 -3 -1 0 1 2 3 4 5 x y Individual points are connected by line segments. The x axis limits are set between -2 π and 2 π using “xlim”. Plot only the points next; no line segments. 2 π π Set using “xlabel”. Figure window
Background image of page 4
Command prompt Many figure windows can be opened at the same time (1, 2, 3, …).
Background image of page 5

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

View Full DocumentRight Arrow Icon
Command prompt -6 -4 -2 0 2 4 6 -5 -3 -1 0 1 2 3 4 5 x y Now only the (x, y) points are shown – red circles are specified by “ro”. Might like to have higher resolution in x values so points are closer together and cosine function is “smoother” when graphed. 10 2 π x step size
Background image of page 6
Command prompt -6 -4 -2 0 2 4 6 -5 -3 -1 0 1 2 3 4 5 x y 100 2 π Graph looks more continuous. Step size in x is now:
Background image of page 7

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

View Full DocumentRight Arrow Icon
Command prompt Can plot multiple curves in the same graph. Used blue squares for y 1 (larger step size in x 1 ) and red line for y 2 . Added “legend” to identify two different curves on single plot. -6 -4 -2 0 2 4 6 -5 -3 -1 0 1 2 3 4 5 x y y 1 y 2
Background image of page 8
Command prompt Type “help plot” to learn more. ‘bs’ = blue square ‘r^’ = red triangle (pointing up) ‘k:’ = black dotted line
Background image of page 9

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

View Full DocumentRight Arrow Icon
Command prompt Use plotting function to verify identities. () () 2 π x cos x sin 1 - 1 - = + () x sin a -1 = ( ) x cos b -1 = -6 -4 -2 0 2 4 6 1.5708 x a + b 1.5708 2 π = Plot “a + b”.
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 31

matlab_introduction_2_10_11 - EML 2920 Spring 2011 MATLAB...

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

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