1 / 17

More stuff on plotting

More stuff on plotting. Define x and y and call the plot function. Engineers always add …. Title title(‘y = cos(x)’) X axis label, complete with units xlabel(‘x-axis’) Y axis label, complete with units ylabel(‘y-axix’) Often it is useful to add a grid grid on. Single quotes are used.

june
Download Presentation

More stuff on plotting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. More stuff on plotting

  2. Define x and y and call the plot function

  3. Engineers always add … • Title title(‘y = cos(x)’) • X axis label, complete with units xlabel(‘x-axis’) • Y axis label, complete with units ylabel(‘y-axix’) • Often it is useful to add a grid grid on Single quotes are used.

  4. Change the line type in a plot • Example plot(x, y, ':ok') • strings are identified with single quotes • the : means use a dotted line • the o means use a circle to mark each point • the letter k indicates that the graph should be drawn in black • (b indicates blue)

  5. Available choices

  6. specify the drawing parameters for each line after the ordered pairs that define the line

  7. Subplots • The subplot command allows you to subdivide the graphing window into a grid of m rows and n columns • subplot(m,n,p) rows columns location

  8. subplot(2,2,1) 2 columns 2 1 2 rows 3 4

  9. 2 rows and 1 column

  10. Other Types of 2-D Plots • Polar Plots • Logarithmic Plots • Bar Graphs • Pie Charts • Histograms • X-Y graphs with 2 y axes • Function Plots

  11. Three Dimensional Plotting • 3D Line plots (i.e. plot3(x,y,z)) • Surface plots (i.e. mesh(z) and surf(z)) • Contour plots

  12. Mesh plots • mesh(z) plots out a 3D plot • The z-axis are the values of ‘z’ • The x-axis is each point corresponding to a column • The y-axis is each point corresponding to a row Example: Z = [1 2 3; 4 5 6]mesh(Z)

  13. Mesh plots continued… • Can also do mesh(x,y,z)  this allows the x and y axis to be something else other than the number of rows and columns • x and y need to have the same dimensions as z. • If x and y are vectors, need to use meshgrid to make them a 2D matrix.

  14. meshgrid example Example: Z = [1 2 3; 4 5 6] %2x3 matrixx=[0:3:6] %number of columns is 3 y=[0:6:6] %number of rows is 2 [X,Y] = meshgrid(x,y) %new X and Y that are 2x3 matrices mesh(X,Y,Z) xlabel(‘X’) ylabel(‘Y’) zlabel(‘Z’)

  15. meshgrid example output Z = 1 2 3 4 5 6 x = 0 3 6 y = 0 6 X = 0 3 6 0 3 6 Y = 0 0 0 6 6 6

  16. surf plots • A surf plot is basically the same as mesh plot except that surf plots give a color surface instead of a mesh Ex: surf(X,Y,Z)

  17. In-class assignment • Problems 4.6, 4.7, and 4.9 from the Matlab book

More Related