1 / 16

EGR106 Week 6

EGR106 Week 6. MATLAB FILES Two Dimensional Plots Multiple Plots Plot Formatting Homework. MATLAB Files. Script files (m files) Text files Contain MATLAB commands Data Files (mat files) binary files Contain arrays (data) Use “save” and “load” commands to write and read.

ziva
Télécharger la présentation

EGR106 Week 6

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. EGR106 Week 6 • MATLAB FILES • Two Dimensional Plots • Multiple Plots • Plot Formatting • Homework

  2. MATLAB Files • Script files (m files) • Text files • Contain MATLAB commands • Data Files (mat files) • binary files • Contain arrays (data) • Use “save” and “load” commands to write and read

  3. Two Dimensional Plots • Line type • plot(x,y,’--’) gives a dashed line • Line color • plot(x,y,’g’) gives a green line • Line thickness • Markers • plot(x,y,’--r*’,’linewidth’,2,’markersize’,12) • Dashed red line with * marker

  4. Multiple Plots • Plot(x, y1, x, y2) Plots y1 and y2 vs x • hold on • Keeps the plot window open for additional lines on the same plot • hold off • Stops writing to the plot • subplot(n,m,k) • Selects plot k in an nxm array of plots. • Used for multiple plots on the same page.

  5. Plot Formatting • xlabel, ylabel • xlabel(‘time (sec)’) • title • title(‘Problem 3 Solution’) • text • text(x,y,’your message at coordinates x,y’) • legend • legend(‘first curve’,’second curve’) • used for multiple curves on a single plot

  6. Plot Formatting • Subscripts and superscripts • Greek letters • Rotating text

  7. Line Properties and Values plot(x,y, 'linewidth',5 ) line width is 5 “points”

  8. >> x=0:2:10; >> y=x.^2; >> plot(x,y,'--r*','linewidth',2,'markersize',12) >> text(2,50,'\fontsize{30} \alpha Profit= x^2 ', 'rotation',45)

  9. Line Specifiers plot(x,y, ' r : d ' ) red dotted line diamonds

  10. Multiple Plots on the Same Axes • Plot allows multiple sets of arrays and line specifiers: Note colors rotate

  11. Two Useful Commands • figure • alone it opens a new window • figure(n) takes you to window n • ginput(1) • creates crosshairs on the screen • returns (x,y) location of cursor at mouse click • ginput(n) returns n pairs of locations

  12. Formatting Plots – Adding Text • Week 1: • xlabel( 'string' ) • ylabel( 'string' ) • title( 'string' ) • text( x, y, 'string' ) • New: • gtext( 'string' ) – cursor controlled • legend( 'string1', … 'stringn', loc)

  13. Multiple Axes in One Figure - Subplot subplot(2,2,1) plot(x1,y1) subplot(2,2,2) etc. Argument is rows, columns, choice

  14. Other Types of 2-D Plots - Polar x = 1:100; r = log10(x); t = x/10; polar( t, r ) magnitude angle in radians

  15. Other Notes • Line specifiers, properties, axis, grid, … work on many of the plot types • Most of these tools have additional features – use the help function • 3-dimensional plots are available (chapter 9) with viewpoint options

More Related