week04 - Rutgers University School of Engineering Fall 2011...

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

View Full Document Right Arrow Icon
Rutgers University School of Engineering Fall 2011 14:440:127 - Introduction to Computers for Engineers Sophocles J. Orfanidis ECE Department orfanidi@ece.rutgers.edu week 4
Background image of page 1

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

View Full DocumentRight Arrow Icon
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) Week 6 - Input-output formatting – fprintf, sprintf (ch. 7) Week 7 - Program flow control & relational operators (ch. 8) Week 8 - Matrix algebra – solving linear equations (ch. 9) Week 9 - Structures & cell arrays (ch. 10) Week 10 - Symbolic math (ch. 11) Week 11 - Numerical methods – data fitting (ch. 12) Week 12 – Selected topics Weekly Topics Textbook: H. Moore, MATLAB for Engineers , 2 nd ed., Prentice Hall, 2009
Background image of page 2
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 contour, contourf mesh, meshc, meshz, waterfall surf, surfc, colormap, colorbar, shading surfaces of revolution convhull, voronoi, spy, gplot animated plots, drawnow, getframe, movie
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
>> 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. 0 1 2 3 4 5 -1 -0.5 0 0.5 1 x y
Background image of page 5

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

View Full DocumentRight Arrow Icon
>> 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)'); 0 1 2 3 4 5 -1 -0.5 0 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.
Background image of page 6
>> 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 0 1 2 3 4 5 -1 -0.5 0 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.
Background image of page 7

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

View Full DocumentRight Arrow Icon
0 1 2 3 4 5 -1 -0.5 0 0.5 1 x y y = f(x) = e -0.5x sin(5x) e -0.5x sin(5x) e -0.5x -e -0.5x >> ye = exp(-0.5*x); % envelope of f(x) >> plot(x,y, ' b- ', x,ye, ' r-- ' , x,-ye, ' m-- ' ); >> xlabel('x'); ylabel( ' y ' ); grid; >> title('f(x) = e^{-0.5x} sin(5x)'); >> legend('e^{-0.5x} sin(5x)', 'e^{-0.5x}', . ..
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 65

week04 - Rutgers University School of Engineering Fall 2011...

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

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