1 / 22

Al Imam Mohammad Bin Saud Islamic University College of Sciences Department of Mathematics

Al Imam Mohammad Bin Saud Islamic University College of Sciences Department of Mathematics. MATLAB 251 : MATH SOFTWARE Introduction to MATLAB. mrs. Asra Sultana. Introduction to MATLAB. 4. Graphics in MATLAB. Introduction to Matlab. 4.1 Main functions. Introduction to Matlab.

phuoc
Télécharger la présentation

Al Imam Mohammad Bin Saud Islamic University College of Sciences Department of Mathematics

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. Al Imam Mohammad Bin Saud Islamic University College of SciencesDepartment of Mathematics MATLAB 251 : MATH SOFTWARE Introduction to MATLAB mrs.Asra Sultana

  2. Introduction to MATLAB 4. Graphics in MATLAB

  3. Introduction to Matlab 4.1 Main functions

  4. Introduction to Matlab To put mathematics in labels you can use matlab’s backslash notation (familiar to users of the TEX typesetting system)

  5. Introduction to Matlab 4.2 2D Graphics Plot symbols and colors may be obtained when we use one of the 4 first previous commands, by adding a string S in those commands. PLOT(X,Y,S) or PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,…)

  6. Introduction to Matlab >> x= linspace(1,10,20); >> y=sin(x);z=cos(x); >> plot(x,y,'-.',x,z,'r') >> t = 0:.1:2*pi; >> subplot(2,2,1) >> plot(cos(t),sin(t)) >> subplot(2,2,2) >> plot(cos(t),sin(2*t)) >> subplot(2,2,3) >> plot(cos(t),sin(3*t)) >> subplot(2,2,4) >> plot(cos(t),sin(4*t))

  7. Introduction to Matlab 4.3 Graphic symbols

  8. Introduction to Matlab 4.4 Clearing the Figure Window You can clear the plot window by typing clf, which stands for ‘clear figure’. To get rid of a figure window entirely, type close. To get rid of all the figure windows, type close all. New figure windows can be created by typing figure. 4.5 Axes So far we have allowed matlab to choose the axes for our plots. You can change the axes in many ways: axis([xminxmaxyminymax]) sets the axes’ minimum and maximum values. • axis square makes the axes the same length • axis equal makes the axes the same scale • axis tight sets the axes limits to the range of the data • axis auto allows matlab to choose axes limits • axis off removes the axes leaving only the plotted data • axis on puts the axes back again

  9. Introduction to Matlab 4.6 3D graphics 1. Elementary commands (using matrix) 2. Elementary commands (math functions) 3. Tools commands

  10. Introduction to Matlab Examples: >> t=0:.1:2*pi; >> plot3(cos(3*t),sin(3*t),t) >> [X,Y]=meshgrid(-10:10); >> Z=sqrt(X.^2+Y.^2); >> mesh(X,Y,Z)

  11. Introduction to Matlab An interesting function: peaks function >> [X,Y,Z]=peaks; >> mesh(X,Y,Z) >> [X,Y,Z]=peaks; >> surf(X,Y,Z)

  12. Introduction to Matlab >>shading interp; >>axis tight; >>colorbar;

  13. Introduction to Matlab >> [X,Y,Z]=peaks; >> contour(X,Y,Z) >> [X,Y,Z]=peaks; >> plot3(X,Y,Z) >> [X,Y,Z]=peaks; >> surfc(X,Y,Z); >>shading flat;

  14. Introduction to Matlab Suppose we have the set of(X,Y) coordinates The (x,y) can be split into two matrices >>x=[1:4];y=[1:4]; >>[X,Y]=meshgrid(x,y) This is meshgrid principle

  15. Introduction to MATLAB • 4.7 Color Maps • Matlab uses a matrix called colormapto color surfaces or images. • The colormap is a list of triplets corresponding To the intensities between 0 and 1 of the red, green and blue You can create your own colormaps or use any matlab predefined colormaps

  16. Introduction to Matlab hsv hot gray bone copper pink white flag lines colorcube jet prism cool autumn spring winter summer Carry out the following commands and observe >>peaks; >>colormap(gray(8)) >>m = gray(8); >>imagesc(colormap(m))

  17. Introduction to Matlab 4.8 Specialized graphs

  18. Introduction to Matlab >> t = [-2:2]’; >> y = [5 2 1; 8 7 3; 9 8 7; 5 5 5;4 3 2];

  19. Introduction to Matlab >> bar(t,y,’stack’) >> bar(t,y)

  20. Introduction to Matlab >> area(t,y) >> bar3(t,y)

  21. Introduction to Matlab >> pie([31 15 8]) >> hist(randn(1000,3))

  22. Introduction to Matlab

More Related