# week04 - Rutgers University School of Engineering Spring...

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

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

View Full Document

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

View Full Document

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

View Full Document

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.

Unformatted text preview: Rutgers University School of Engineering Spring 2012 14:440:127 - Introduction to Computers for Engineers Sophocles J. Orfanidis ECE Department [email protected] week 4 Week 1 - Basics – variables, arrays, matrices, plotting (ch. 2 & 3) Week 2 - Basics – operators, functions, program flow (ch. 2 & 3) Week 3 - Matrices (ch. 4) Week 4 - Plotting – 2D and 3D plots (ch. 5) Week 5 - User-defined functions (ch. 6) – Exam 1 Week 6 - Input-output formatting – fprintf, fscanf (ch. 7) Week 7 - Program flow control & relational operators (ch. 8 & 9) Week 8 - Program flow control & relational operators (ch. 8 & 9) Week 9 - Matrix algebra – solving linear equations (ch. 10) Week 10 - Cell arrays and structures (ch. 11) – Exam 2 Week 11 - Numerical methods – part I (ch. 13) Week 12 - Numerical methods – part II (ch. 13) Week 13 - Symbolic toolbox (ch. 12) Week 14 - Exam 3 Weekly Topics Textbook: H. Moore, MATLAB for Engineers , 3 d ed., Prentice Hall, 2011 Plotting plot, line styles, colors, markers, multiple graphs adding text, legends, plot editor axis settings, subplots fplot, ezplot, loglog, semilogy, plotyy scatter, stem, stairs bar graphs, histograms, pie charts, polar plots 3D plotting functions, meshgrid plot3, stem3, bar3, pie3, comet3 contour, contourf mesh, meshc, meshz, waterfall, area plots surf, surfc, colormap, colorbar, shading surfaces of revolution convhull, voronoi, spy, gplot animated plots, drawnow, getframe, movie Review from Weeks 1 & 2 MATLAB has extensive facilities for the plotting of curves and surfaces, and visualization. Basic 2D plots of functions and (x,y) pairs can be done with the functions: plot, fplot, ezplot >> help plot % 2-D plotting >> help fplot % function plotting >> help ezplot % easy function plotting >> f = @(x) exp(-0.5*x).*sin(5*x); >> fplot(f,[0,5]); % plot over interval [0,5] If a function f(x) has already been defined by a function- handle or inline, it can be plotted quickly with fplot , ezplot , which are very similar. One only needs to specify the plot range . For example: A figure window opens up, allowing further editing of the graph, e.g., adding x,y axis labels, titles, grid, changing colors, and saving the graph is some format, such as WMF, PNG, or EPS. 1 2 3 4 5-1-0.5 0.5 1 x y >> x = linspace(0,5,101); >> y = f(x); >> plot(x,y, ' b- ' ); % blue-solid line >> xlabel('x'); ylabel( ' y ' ); grid; >> title('f(x) = e^{-0.5x} sin(5x)'); 1 2 3 4 5-1-0.5 0.5 1 x y y = f(x) = e-0.5x sin(5x) using the plot function plot annotation can be done by separate commands, as shown above, or from the plot editor in the figure window. >> x5 = x(1:5:end); % plot every 5 th data point >> y5 = y(1:5:end); >> plot(x,y, ' b- ', x5,y5, ' r. ' ); % blue-line, red dots >> xlabel('x'); ylabel( ' y ' ); grid; >> title('f(x) = e^{-0.5x} sin(5x)'); multiple graphs on same plot 1 2 3 4 5-1-0.5 0.5 1 x y y = f(x) = e-0.5x sin(5x) (x,y) plotted as blue-solid line (x5,y5) pairs plotted as red dots multiple (x,y) pairs---not necessarily of the same size---can be plotted with different line styles. 1...
View Full Document

{[ snackBarMessage ]}

### Page1 / 70

week04 - Rutgers University School of Engineering Spring...

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

View Full Document
Ask a homework question - tutors are online