Exam 3 Review

# 110 y x 2 10 x 15 plotx y plotting data in

This preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: ; Plotting Data in MATLAB To add a title to a graph use the function title( ) To add x and y axis labels use the functions xlabel( ) xlabel( and ylabel( ) ylabel( To add a grid to the graph use the grid function title(`A Parabola'); xlabel(`x xlabel(`x value'); ylabel(`y ylabel(`y value'); grid on; Plotting Data in MATLAB Multiple data sets can be plotted on the same graph x = 0:0.1:10; y1 = x .^2 10 .* x + 15; y2 = - x.^2 + 10 .* x; plot(x, y1, x, y2); Plotting Data in MATLAB Multiple data sets can be plotted on the same graph Here one will be red and dot-dashed, and the other will dotbe blue and marked with circles A legend is created with the legend function x = 0:0.1:10; y1 = x .^2 10 .* x + 15; y2 = - x.^2 + 10 .* x; plot(x, y1, `r_.', x, y2, `bo'); legend(`parabola up', `parabola down'); 10 Three Dimensional Plots t = 0:0.1:10; x = exp(-0.2*t) .* cos(2*t); exp(y = exp(-0.2*t) .* sin(2*t); exp(plot(x,y); This produces a 2d plot, but it tells us nothing about time. Three Dimensional Plots t = 0:0.1:10; x = exp(-0.2*t) .* cos(2*t); exp(y = exp(-0.2*t) .* sin(2*t); exp(plot3(x, y, t); Now we can immediately see the time dependence. Three Dimensional Plots The simplest way to plot is a pseudocolor plot pcolor(x, y, z); You can also plot contours contour(x, y, z); contourf(x, y, z); %filled contour Perspective views can be obtained with mesh(x, y, z); meshc(x, y, z); % with contour surf(x, y, z); surfc(x, y, z); % with contour surfl(x, y, z); % with lighting Good luck on the exam! 11...
View Full Document

## This note was uploaded on 05/04/2010 for the course ENGIN 101 taught by Professor Jeffringenberg during the Spring '07 term at University of Michigan.

Ask a homework question - tutors are online