matlab example programs

Upload: grtabhilkw

Post on 13-Feb-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 matlab example programs

    1/15

    %Design of FIR Band Stop Filter withTriangular Window

    clear all

    clcfs=5000;f1=2*1000/fs;f2=2*2000/fs;fn=[f1 f2];n=30;

    win=window(@triang, n+1);s!"lot(221);ste#(win,$r$);grid on;%la!el(&ti#e$);'la!el(&a#"$);title(&rianglar indow$);

    !=rl(n,fn,$!andsto"$,win);s!"lot(222);ste#(!,$$);grid on;%la!el(&ti#e$);

    'la!el(&a#"$);title("lse -es"onse$);[. o#]=fre(!);

    s!"lot(223);"lot(o#/(2*"i)*fs,20*log10(a!s(.)),$#$);

    grid on;

  • 7/23/2019 matlab example programs

    2/15

    %la!el(&freenc'$);'la!el(ag$);title(&agnitde -es"onse$);

    s!"lot(22);"lot(o#/(2*"i)*fs,nwra"(angle(.))*543,$!$);grid on;%la!el(&frenc'$);'la!el(&".ase$);

    title(&.ase -eas"onse$);

  • 7/23/2019 matlab example programs

    3/15

    %Design of FIR Band Pass Filter withHanning Window

    clear all

    clcfs=5000;f1=2*1000/fs;f2=2*2000/fs;fn=[f1 f2];n=66;win=window(@.a##ing, n+1);s!"lot(221);ste#(win,$r$);grid on;%la!el(&ti#e$);'la!el(&a#"$);title(&7a##ing indow$);

    !=rl(n,fn,$!and"ass$,win);s!"lot(222);ste#(!,$$);grid on;%la!el(&ti#e$);

    'la!el(&a#"$);

  • 7/23/2019 matlab example programs

    4/15

    title("lse -es"onse$);[. o#]=fre(!,1,512);

    s!"lot(223);"lot(o#/(2*"i)*fs,20*log10(a!s(.)),$#$);grid on;%la!el(&freenc'$);'la!el(ag$);title(&agnitde -es"onse$);

    s!"lot(22);"lot(o#/(2*"i)*fs,nwra"(angle(.))*543,$!$);grid on;%la!el(&freenc'$);'la!el(&".ase$);title(&.ase -es"onse$);

  • 7/23/2019 matlab example programs

    5/15

    %Design of FIR High Pass Filter withHamming Window

    clear allclcfs=2000;f"=500;fn=2*f"/fs;n=30;win=window(@.a##ing, n+1);s!"lot(221);ste#(win,$r$);

    grid on;%la!el(&ti#e$);'la!el(&a#"$);title(&7a##ing indow$);

    !=rl(n,fn,$.ig."ass$,win);

    s!"lot(222);

  • 7/23/2019 matlab example programs

    6/15

    ste#(!,$$);grid on;%la!el(&ti#e$);

    'la!el(&a#"$);title("lse -es"onse$);[. o#]=fre(!);

    s!"lot(223);"lot(o#/(2*"i)*fs,20*log10(a!s(.)),$#$);

    grid on;%la!el(&freenc'$);'la!el(ag$);title(&agnitde -es"onse$);

    s!"lot(22);"lot(o#/(2*"i)*fs,nwra"(angle(.))*543,$!$);grid on;%la!el(&freenc'$);'la!el(&".ase$);title(&.ase -es"onse$);

  • 7/23/2019 matlab example programs

    7/15

    %Design of FIR Low Pass Filter withFlattop Window

    clear allclcfs=000;f"=00;

    fn=2*f"/fs;n=30;win=window(@8atto"win, n+1);s!"lot(221);ste#(win,$r$);grid on;

    %la!el(&ti#e$);

  • 7/23/2019 matlab example programs

    8/15

    'la!el(&a#"$);title(&9latto" indow$);

    !=rl(n,fn,$low"ass$,win);s!"lot(222);ste#(!,$$);grid on;%la!el(&ti#e$);'la!el(&a#"$);

    title("lse -es"onse$);[. o#]=fre(!);

    s!"lot(223);"lot(o#/(2*"i)*fs,20*log10(a!s(.)),$#$);grid on;%la!el(&freenc'$);'la!el(ag$);title(&agnitde -es"onse$);

    s!"lot(22);"lot(o#/(2*"i)*fs,nwra"(angle(.))*543,$!$);grid on;

    %la!el(&freenc'$);'la!el(&".ase$);title(&.ase -es"onse$);

  • 7/23/2019 matlab example programs

    9/15

    %Correlation of two funtions

    clcclear

    %=[1 2 3 2 6 : ]'=[3 6 5 2 3 6 6]

    %=%corr(%,')

  • 7/23/2019 matlab example programs

    10/15

    s!"lot(211);"lot(%);grid on;

    %la!el(&i#e(sec)$);'la!el(&

  • 7/23/2019 matlab example programs

    11/15

    =con?();

    s!"lot(311);"lot($);

    %"eneration of Sine signals withdi#erent fre$uenies

    clearclc

    fre=10;

  • 7/23/2019 matlab example programs

    12/15

    sa#"Cfre=100*fre;t=0D(1/sa#"Cfre)D1;%=sin(2*"i*fre*t);

    s!"lot(311);"lot(t,%);grid on;%la!el(&i#e(sec)$);'la!el(&

  • 7/23/2019 matlab example programs

    13/15

    'la!el(&

  • 7/23/2019 matlab example programs

    14/15

    %"eneration of Random Signalclearclc

    t=0D0401D10;ran=rand(1,lengt.(t));"lot(t,ran);grid on;%la!el(&i#e(sec)$);'la!el(&

  • 7/23/2019 matlab example programs

    15/15