{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

matlab_introduction_2_10_11

# matlab_introduction_2_10_11 - EML 2920 Spring 2011 MATLAB...

This preview shows pages 1–11. 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
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.

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

View Full Document
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
Command prompt Many figure windows can be opened at the same time (1, 2, 3, …).

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

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

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

View Full Document
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
Command prompt Type “help plot” to learn more. ‘bs’ = blue square ‘r^’ = red triangle (pointing up) ‘k:’ = black dotted line

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

View Full Document
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”.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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