6
function sinx x=linspace(0,2*pi); figure(1) hold on plot(x,sin(x),'r') plot(x,cos(x),'b') plot(x,tan(x),'g') axis([0 2*pi -2 2]) grid on legend('sinx','cosx','tanx') Published with MATLAB® 7.11 1

Coursework Template

Embed Size (px)

DESCRIPTION

MATLAB

Citation preview

  • function sinxx=linspace(0,2*pi);figure(1)hold onplot(x,sin(x),'r')plot(x,cos(x),'b')plot(x,tan(x),'g')axis([0 2*pi -2 2])grid onlegend('sinx','cosx','tanx')

    Published with MATLAB 7.11

    1

  • function gauss1[x,y]=meshgrid(-pi:2*pi/6:pi,-pi:2*pi/6:pi);gauss=exp(-x.^2-y.^2);mesh(gauss)plot(gauss)legend('exp(-x.^2-y.^2)')

    Published with MATLAB 7.11

    1

  • function gauss2[a,b]=meshgrid(-pi:2*pi/99:pi,-pi:2*pi/99:pi);gauss=(exp(-a.^2-b.^2));mesh(gauss)plot(gauss)legend('exp(-a.^2-b.^2)')

    Published with MATLAB 7.11

    1

  • function sinpowericount=0linecolor='rgbmcykrbm';x=linspace(0,2*pi);figure(1)hold onfor i = 1:10;

    icount=icount+1;plot(x,sin(x).^i,linecolor(icount));

    endaxis([0 2*pi -2 2])grid onhold off

    icount =

    0

    Published with MATLAB 7.11

    1

  • function cospowericount=0linecolor='rgbmcykrbm';x=linspace(0,2*pi);figure(1)hold onfor i = 1:10;

    icount=icount+1;plot(x,cos(x).^i,linecolor(icount));

    endaxis([0 2*pi -2 2])grid onhold off

    icount =

    0

    Published with MATLAB 7.11

    1

  • 1sinx Name Size Bytes Class Attributes

    x 1x100 800 double

    em398_coursework_templategauss1 Name Size Bytes Class Attributes

    gauss 7x7 392 double x 7x7 392 double y 7x7 392 double

    gauss2 Name Size Bytes Class Attributes

    a 100x100 80000 double b 100x100 80000 double gauss 100x100 80000 double

    sinpower

    icount =

    0

    Name Size Bytes Class Attributes

    i 1x1 8 double icount 1x1 8 double linecolor 1x10 20 char x 1x100 800 double

    cospower

    icount =

    0

    Name Size Bytes Class Attributes

    i 1x1 8 double icount 1x1 8 double linecolor 1x10 20 char x 1x100 800 double

    Error: File: \\myfiles\em398\dos\MATLAB\Variables.m Line: 23 Column: 9Expression or statement is incomplete or incorrect.

    Published with MATLAB 7.13

    sinx

    gauss1

    gauss2

    sinpower

    cospower