Matlab Lec 2

download Matlab Lec 2

of 6

Transcript of Matlab Lec 2

  • 8/19/2019 Matlab Lec 2

    1/12

    MATLAB

    LEC 2

    ENG/Ahmed Atef 

  • 8/19/2019 Matlab Lec 2

    2/12

    %s - print a string

    %c - print a single character

    %d - print a whole numer%f - print a floating point numer

     \ n - print a new line !go to the ne"t line to continue printing#

     \ t - print a ta

     \\ -print a slash

    %% -print a percent sign

    http$//www%cs%utah%edu/&germain/''(/Topics/Matla/fprintf%html

  • 8/19/2019 Matlab Lec 2

    3/12

    for i)*$*+

    disp!i#

    end

     

    for i)*$*+

    fprintf! ,f d .n,s0rt!i#i#

    end

  • 8/19/2019 Matlab Lec 2

    4/12

    for  ")+$pi/1$pi

    fpirntf !,+%f %2f .n,sin!"#cos!"##

    end

  • 8/19/2019 Matlab Lec 2

    5/12

    ")3+$pi/1+$24pi5

    6)sin!"#7)cos!"#

    plot!"6,green %,#

  • 8/19/2019 Matlab Lec 2

    6/12

    E"$2

    ")3+$pi/1+$24pi56)sin!"#

    7)cos!"#

    plot!"6,green -,#

    holdplot!"7,lue -,#

    ")3+$pi/1+$24pi56)sin!"#7)cos!"#

    plot!"6,green -,"7,lue -,#

  • 8/19/2019 Matlab Lec 2

    7/12

    ")3+$pi/1+$24pi56)sin!"#7)cos!"#

    plot!"6,green -,"7,lue -,# 

    legend!,sing!"#,,cos!"#,#

    grid on"lael!,; A"is,#6lael!,< A"is,#title!,Graph test 2=,#

  • 8/19/2019 Matlab Lec 2

    8/12

    (uplot!num of rows num of columnso" num#

    (uplot! 2o" num#

    Box Num 2 Box Num 1

    Bo" Num > Bo" Num

    Bo" Num 1 Bo" Num ? 

  • 8/19/2019 Matlab Lec 2

    9/12

    ")3+$pi/1+$24pi5;

    6)sin!"#;

    7)cos!"#;

     

    suplot!2*#;

    plot!"6,green -,#

    grid

     

    suplot!2>#;

    plot!"7,lue -,#

    grid

  • 8/19/2019 Matlab Lec 2

    10/12

    3D

    ")3-@$+%+?$@5

    6)"r)s0rt!"%296%2#;

    7)sin!r#%/r;

    plot!"67,m -,#;

     

    title!,= Line Graph,#

    "lael!,; a"is,#

    6lael!,< a"is,#

    7lael!, a"is,#

  • 8/19/2019 Matlab Lec 2

    11/12

  • 8/19/2019 Matlab Lec 2

    12/12

    TDAN(