Your SlideShare is downloading. ×
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Matlab: Graph Plots
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Matlab: Graph Plots


Published on

Plotting using Matlab

Plotting using Matlab

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Matlab: Graph Plots<br />
  • 2. Tools for plotting<br />plot- plot(y) plots the values in vector y versus their index.  plot(x,y) plots the values in vector y versus x. The plot function produces a piecewise linear graph between its data values. With enough data points it looks continuous.<br />stem- Using stem(y) the data sequence y is plotted as stems from the x-axis terminated with circles for the data values. stem(x,y) plots the data sequence y at the values specified in x.<br />
  • 3. Tools for plotting<br />xlabel(&amp;apos;string&amp;apos;) - Labels the x-axis with string.<br />ylabel(&amp;apos;string&amp;apos;) - Labels the y-axis with string.<br />title(&amp;apos;string&amp;apos;) - Gives the plot the title string.<br />
  • 4. Tools for plotting<br />hold on / off - Normally hold is off. This means that the plot command replaces the current plot with the new one. To add a new plot to an existing graph use hold on. If you want to overwrite the current plot again, use hold off.<br />legend(&amp;apos;plot1&amp;apos;,&amp;apos;plot2&amp;apos;,...,&amp;apos;plot N&amp;apos;) - The legend command provides an easy way to identify individual plots when there are more than one per figure.<br />axis([xminxmaxyminymax])- Use the axis command to set the axis as you wish.<br />
  • 5. Tools for plotting<br />subplot(m,n,p) -Divides the figure window into m rows, n columns and selects the pp&amp;apos;th subplot as the current plot, e.g subplot(2,1,1) divides the figure in two and selects the upper part. subplot(2,1,2) selects the lower part.<br />grid on/off - This command adds or removes a rectangular grid to your plot.<br />
  • 6. Graph Components<br />The following picture shows the basic components of a typical graph.<br />
  • 7. 2-D plotting<br />To plot the function:<br />y = x2 for x 2 [-2; 2].<br /><ul><li>x = -2:0.2:2;
  • 8. y = x.^2;
  • 9. figure(1);
  • 10. plot(x,y);
  • 11. xlabel('x');
  • 12. ylabel('y=x^2');
  • 13. title('Simple plot');
  • 14. figure(2);
  • 15. stem(x,y);
  • 16. xlabel('x');
  • 17. ylabel('y=x^2');
  • 18. title('Simple stem plot');</li></li></ul><li>2-D plotting<br /><ul><li>x = -3:0.2:3; y1 = -x.^2; y2 = x.^2;
  • 19. subplot(2,1,1);
  • 20. plot(x,y1);
  • 21. xlabel('x'); ylabel('y_1=-x^2');
  • 22. gridon;
  • 23. subplot(2,1,2);
  • 24. plot(x,y2);
  • 25. xlabel('x');
  • 26. ylabel('y_2=x^2');</li></li></ul><li>2-D plotting<br /><ul><li>t = 0:pi/20:2*pi;
  • 27. y = exp(sin(t));
  • 28. plotyy(t,y,t,y,'plot','stem')
  • 29. xlabel('X Axis')
  • 30. ylabel('Plot Y Axis')
  • 31. title('Two Y Axes')</li></li></ul><li>3-D Graphics<br /><ul><li>[x,y] = meshgrid(-3:.1:3);
  • 32. z = x.^2+y.^2;
  • 33. mesh(x,y,z);
  • 34. xlabel('x');
  • 35. ylabel('y');
  • 36. zlabel('z=x^2+y^2');</li></li></ul><li>Visit more self help tutorials<br />Pick a tutorial of your choice and browse through it at your own pace.<br />The tutorials section is free, self-guiding and will not involve any additional support.<br />Visit us at<br />