dsp practicals

Upload: abhishek-srivastava

Post on 07-Apr-2018

251 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/4/2019 DSP Practicals

    1/35

    BSP Practical Lab Manual

    1. AimWrite a program to display a continuous time sine waveform along with its

    sampled version

    Program

    clcA =input('Enter the amplitude A=');

    f0=input('Enter the signal frequency in hz f0 =');

    ph=input('Enter the initial phase angle in radians ph =');

    fs=input('Enter the sampling frequency fs=');c =input('No of cycles to be displayed c=');

    t= 0:0.01/fs:c*1/f0;

    x= A*sin(2*pi*f0*t +ph);

    subplot(2,1,1)plot(t,x);

    title('continuous sine wave');

    xlabel('time ');ylabel('Amplitude');

    grid

    subplot(2,1,2)x1= x([1:50:length(x)]);

    n=0:1:length(x1)-1;stem(n,x1)title('sampled sine wave');

    xlabel('time (n)');

    ylabel('Amplitude(A)');grid

    Input

    The given sample input for this program is:

    Enter the amplitude A=5

    Enter the signal frequency in hz f0 =50

    Enter the initial phase angle in radians ph = 45Enter the sampling frequency fs=200

    No of cycles to be displayed c=5

  • 8/4/2019 DSP Practicals

    2/35

    Output

    0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1-5

    0

    5continuous sine wave

    time

    Amplitude

    0 5 10 15 20 25 30 35 40-5

    0

    5sampled sine wave

    time (n)

    Amplitude(A

    )

    Conclusion

    Thus we had obtained the continuous sine wave along with sampled version using sampleinput values.

  • 8/4/2019 DSP Practicals

    3/35

    2. AimWrite a program to show the convolution of two sequences x(n) & h(n) which

    are input from keyboard.

    Program

    x = input('Enter the first sequence x(n) = ');

    h = input('Enter the second sequence h(n) = ');y = conv (x,h);

    k = length(x) + length(h) -1;

    n = 1:k ;

    stem(n,y);title('Convoluted signal ');

    xlabel('Time');

    ylabel('Amplitude');

    grid ON;

    Input

    The given sample input for this program is:

    Enter the first sequence x(n) = [1 3 5 7]

    Enter the second sequence h(n) = [2 4 6 8]

    Output

    1 2 3 4 5 6 70

    10

    20

    30

    40

    50

    60

    70

    80

    90Convolutedsignal

    Time

    Amplitude

  • 8/4/2019 DSP Practicals

    4/35

    Conclusion

    Thus we had obtained the convoluted signal output of the two sample input sequences.

  • 8/4/2019 DSP Practicals

    5/35

    3. Aimwrite a program tofind the circular convolution of two sequences input fromthe keyboard using DFT.

    Program

    clc;

    clear all;

    x = input( ' Enter the first sequence x(n)=');

    h = input( ' Enter the second sequence h(n)=');

    N1 = length(x);N2 = length(h);

    if N1>N2

    h = [h,zeros(N1-N2)];

    end

    if N1

  • 8/4/2019 DSP Practicals

    6/35

    ylabel('Amplitude');

    grid ON;

    Input

    The given sample input for this program is:

    Enter the first sequence x(n) = [1 3 5 7]Enter the second sequence h(n) = [2 4 6 8]

    Output

    0 0.5 1 1.5 2 2.5 30

    5

    10Sequence x(n)

    Time

    Amplitude

    0 0.5 1 1.5 2 2.5 30

    5

    10Sequence h(n)

    Time

    Amplitude

    0 0.5 1 1.5 2 2.5 30

    50

    100Circular Convolution

    Time

    Amplitude

    Conclusion

    Thus we had obtained the circular convolution of two sample input sequences and

    represent them individually in each graph.

  • 8/4/2019 DSP Practicals

    7/35

    4. Aim Write a program to compute the DFT of an input sequence from the

    keyboard. Plot the magnitude and phase. [ Use fft and angle functions]

    Program

    clc ;

    clear all;

    x = input('Signal sequence whose DFT to be calculated x(n) : ');n = [0 : length(x)-1];

    radian = 2*pi*n;

    y = fft(x);

    subplot(2,1,1);stem(radian,abs(y));

    title( ' MAGNITUDE DFT[x(n)]');

    xlabel('Radians');

    ylabel('Amplitude');grid ON;

    subplot(2,1,2);stem(radian,angle(y));

    title( ' PHASE PLOT DFT[x(n)]');

    xlabel('Radians');

    ylabel('Phase');grid ON;

    Input

    The given sample input for this program is:

    Signal sequence whose DFT to be calculated x(n): [1 3 5 7]

    Output

  • 8/4/2019 DSP Practicals

    8/35

    0 2 4 6 8 10 12 14 16 18 200

    5

    10

    15

    20MAGNITUDEDFT[x(n)]

    Radians

    Amplitude

    0 2 4 6 8 10 12 14 16 18 20-4

    -2

    0

    2

    4PHASEPLOTDFT[x(n)]

    Radians

    Phase

    Conclusion

    Thus we had obtained the DFT of the input sequence and plotted the sequence using fftand angle function and plotted it on magnitude and phase graph.

  • 8/4/2019 DSP Practicals

    9/35

    5. AimWrite a program to design a FIR filters [LP, HP, BP, BR] using rectangular

    window.

    Program

    clc;

    choice = 0;

    while(choice ~= 5)clc;

    disp('**************MAIN MENU***************');

    disp('------FIR Filter using rectangular window--------');

    disp('1: Low pass filter');disp('2: High pass filter');

    disp('3: Band pass filter');

    disp('4: Band reject filter');

    disp('5: Exit');choice = input('Your Choice :');

    if(choice == 5)break;

    end

    format long;rp=input('enter the passband ripple=');

    rs=input('enter the stopband riple=');

    fp=input('enter the passband freq=');fs=input('enter the stopband freq=');

    f=input('enter the sampling freq=');

    wp=2*fp/f;ws=2*fs/f;

    num=-20*log10(sqrt(rp*rs))-13;dem=14.6*(fs-fp)/f;

    n=ceil(num/dem);

    n1=n+1;

    if(rem(n,2)~=0)n1=n;

    n=n-1;

    endy=boxcar(n1);

    switch(choice)case 1

    b=fir1(n,wp,y);

  • 8/4/2019 DSP Practicals

    10/35

    case 2

    b=fir1(n,wp,'high',y);

    case 3

    wn=[wp ws];b=fir1(n,wn,y);

    case 4

    b=fir1(n,wn,'stop',y);

    end

    [h,o]=freqz(b,1,256);

    m=20*log10(abs(h));

    subplot(2,1,1);plot(o/pi,m);

    ylabel('Gain in db-->');xlabel('(a) Normalized frequency-->');

    end

    Input

    The given sample input for all the filters i.e. LP, HP, BP, BR in this program is:

    FIR filters--rectangular window

    a) Passband ripple=0.05

    b) Stopband ripple=.04c) Passband frequency=1500

    d) Stopband frequency=2000

    e) Sampling frequency=9000

    Output

    Low Pass Filter (LP):

  • 8/4/2019 DSP Practicals

    11/35

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb-->

    (a) Normalized frequency-->

    High Pass Filter (HP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb

    -->

    (a) Normalized frequency-->

    Band Pass Filter (BP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb-->

    (a) Normalized frequency-->

    Band Reject Filter (BR):

  • 8/4/2019 DSP Practicals

    12/35

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-20

    -10

    0

    10

    Gainindb-->

    (a) Normalized frequency-->

    Conclusion

    Thus we have obtained the filter design method for FIR filter using rectangular windowfor all types of filters viz. LP, HP, BP and BR.

  • 8/4/2019 DSP Practicals

    13/35

    6. AimWrite a program to design a FIR filters [LP,HP,BP,BR] using hamming

    window.

    Program

    clear;

    clc;

    choice = 0;while(choice ~= 5)

    clc;

    disp('**************MAIN MENU***************');

    disp('------FIR Filter using hamming window--------');disp('1: Low pass filter');

    disp('2: High pass filter');

    disp('3: Band pass filter');

    disp('4: Band reject filter');disp('5: Exit');

    choice = input('Your Choice :');if(choice == 5)

    break;

    end

    format long;

    rp=input('enter the passband ripple=');

    rs=input('enter the stopband ripple=');fp=input('enter the passband freq=');

    fs=input('enter the stopband freq=');

    f=input('enter the sampling freq=');wp=2*fp/f;

    ws=2*fs/f;

    num=-20*log10(sqrt(rp*rs))-13;

    dem=14.6*(fs-fp)/f;

    n=ceil(num/dem);

    n1=n+1;if(rem(n,2)~=0)

    n1=n;

    n=n-1;end

    y=hamming(n1);

    switch(choice)

    case 1

    b=fir1(n,wp,y);

  • 8/4/2019 DSP Practicals

    14/35

    case 2

    b=fir1(n,wp,'high',y);

    case 3

    wn=[wp ws];

    b=fir1(n,wn,y);

    case 4

    b=fir1(n,wn,'stop',y);

    end

    [h,o]=freqz(b,1,256);m=20*log10(abs(h));

    subplot(2,1,1);plot(o/pi,m);

    ylabel('Gain in db-->');

    xlabel('(a) Normalized frequency-->');

    end

    Input

    The given sample input for all the filters i.e. LP, HP, BP, BR in this program is:

    FIR filters--hamming window

    a) Passband ripple=0.04

    b) Stopband ripple=0.02

    c) Passband frequency=1500

    d) Stopband frequency=2000e) Sampling frequency=8000

    Output

    Low pass filter (LP):

  • 8/4/2019 DSP Practicals

    15/35

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb-->

    (a) Normalized frequency-->

    High pass filter (HP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb-

    ->

    (a) Normalized frequency-->

    Band pass filter (BP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb-->

    (a) Normalized frequency-->

    Band reject filter (BR):

  • 8/4/2019 DSP Practicals

    16/35

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-10

    -5

    0

    5

    Gainindb-->

    (a) Normalized frequency-->

    Conclusion

    Thus we have obtained the filter design method for FIR filter using hamming window

    for all types of filters viz. LP, HP, BP and BR.

  • 8/4/2019 DSP Practicals

    17/35

    7. AimWrite a program to design of FIR filters [LP,HP,BP,BR] using hanning

    window.

    Program

    clear;

    clc;

    choice = 0;while(choice ~= 5)

    clc;

    disp('**************MAIN MENU***************');

    disp('------FIR Filter using hanning window--------');disp('1: Low pass filter');

    disp('2: High pass filter');

    disp('3: Band pass filter');

    disp('4: Band reject filter');disp('5: Exit');

    choice = input('Your Choice :');if(choice == 5)

    break;

    end

    format long;

    rp=input('enter the passband ripple=');

    rs=input('enter the stopband riple=');fp=input('enter the passband freq=');

    fs=input('enter the stopband freq=');

    f=input('enter the sampling freq=');wp=2*fp/f;

    ws=2*fs/f;

    num=-20*log10(sqrt(rp*rs))-13;

    dem=14.6*(fs-fp)/f;

    n=ceil(num/dem);

    n1=n+1;if(rem(n,2)~=0)

    n1=n;

    n=n-1;end

    y=hanning(n1);

    switch(choice)

    case 1

  • 8/4/2019 DSP Practicals

    18/35

    b=fir1(n,wp,y);

    case 2

    b=fir1(n,wp,'high',y);

    case 3

    wn=[wp ws];b=fir1(n,wn,y);

    case 4

    b=fir1(n,wn,'stop',y);

    end

    [h,o]=freqz(b,1,256);

    m=20*log10(abs(h));subplot(2,1,1);

    plot(o/pi,m);

    ylabel('Gain in db-->');

    xlabel('(a) Normalized frequency-->');

    end

    Input

    The given sample input for all the filters i.e. LP, HP, BP, BR in this program is:

    FIR filters--hanning window

    a) Passband ripple=0.03

    b) Stopband ripple=0.01

    c) Passband frequency=1400d) Stopband frequency=2000

    e) Sampling frequency=8000

    Output

    Low pass filter (LP):

  • 8/4/2019 DSP Practicals

    19/35

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150

    -100

    -50

    0

    50

    Gainindb-->

    (a) Normalized frequency-->

    High pass filter (HP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb-->

    (a) Normalized frequency-->

    Band pass filter (BP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150

    -100

    -50

    0

    Gainindb-->

    (a) Normalized frequency-->

    Band reject filter (BR):

  • 8/4/2019 DSP Practicals

    20/35

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-15

    -10

    -5

    0

    5

    Gainindb-->

    (a) Normalized frequency-->

    Conclusion

    Thus we have obtained the filter design method for FIR filter using hanning window

    for all types of filters viz. LP, HP, BP and BR.

  • 8/4/2019 DSP Practicals

    21/35

    8. AimWrite a program to design digital Butterworth filters [ LP, HP, BP, BR ] for

    the following specifications

    a)Pass band ripple

    b)Pass band frequency

    c)Stop band ripple

    d)Stop band frequencye)Sampling frequeny

    Use buttord, butter and freqz functions. Plot the amplitude and phase response.

    Program

    clear;clc;

    choice = 0;

    while(choice ~= 5)

    clc;disp('**************MAIN MENU***************');

    disp('------Butterworth Filter--------');disp('1: Low pass filter');

    disp('2: High pass filter');

    disp('3: Band pass filter');

    disp('4: Band reject filter');disp('5: Exit');

    choice = input('Your Choice :');

    if(choice == 5)break;

    end

    format long;

    rp=input('enter the passband ripple=');

    rs=input('enter the stopband riple=');wp=input('enter the passband freq=');

    ws=input('enter the stopband freq=');

    fs=input('enter the sampling freq=');

    w1=2*wp/fs;w2=2*ws/fs;

    switch(choice)case 1

    [n,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(n,wn);

    case 2

  • 8/4/2019 DSP Practicals

    22/35

    [n,wn]=buttord(w1,w2,rp,rs);

    [b,a]=butter(n,wn,'high');

    case 3

    [n]=buttord(w1,w2,rp,rs);wn=[w1 w2];

    [b,a]=butter(n,wn,'bandpass');

    case 4

    [n]=buttord(w1,w2,rp,rs);

    wn=[w1 w2];[b,a]=butter(n,wn,'stop');

    end

    w=0:.01:pi;[h,om]=freqz(b,a,w);

    m=20*log10(abs(h));

    an=angle(h);

    subplot(2,1,1);plot(om/pi,m);

    ylabel('Gain in db-->');

    xlabel('(a) Normalized frequency-->');subplot(2,1,2);

    plot(om/pi,an);

    xlabel('(b) Normalized frequency-->');ylabel('phase in radians-->');

    end

    Input

    The given sample input for all the filters i.e. LP, HP, BP, BR in this program are:

    1) Butterworth low pass and high pass filters (LP & HP):

    a) Passband ripple=0.5

    b) Stopband ripple=50

    c) Passband frequency=1200d) Stopband frequency=2400

    e) Sampling frequency=10000

    2) Butterworth band pass filter (BP):

  • 8/4/2019 DSP Practicals

    23/35

    a) Passband ripple=0.3

    b) Stopband ripple=40c) Passband frequency=1500

    d) Stopband frequency=2000

    e) Sampling frequency=9000

    3) Butterworth band reject filter (BR):

    a) Passband ripple=0.4

    b) Stopband ripple=46

    c) Passband frequency=1100

    d) Stopband frequency=2200e) Sampling frequency=6000

    Output

    1) Butterworth low pass filter (LP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400

    -200

    0

    200

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradians-->

    2) Butterworth high pass filter (HP):

  • 8/4/2019 DSP Practicals

    24/35

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-300

    -200

    -100

    0

    100

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phasein

    radians-->

    3) Butterworth band pass filter (BP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-800

    -600

    -400

    -200

    0

    Gainindb--

    >

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradia

    ns-->

  • 8/4/2019 DSP Practicals

    25/35

    4) Butterworth band reject filter (BR):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-300

    -200

    -100

    0

    100

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinrad

    ians-->

    Conclusion

    Thus we have obtained the filter design method for Butterworth filter for all types of

    filters viz. LP, HP, BP and BR.

  • 8/4/2019 DSP Practicals

    26/35

    9. AimWrite a program to design digital Chebyshev Type-I filters [ LP, HP, BP, BR]

    for the following specifications

    a) Pass band ripple

    b) Pass band frequency

    c) Stop band ripple

    d) Stop band frequencye) Sampling frequency

    Use cheb1ord, cheby1 and freqz functions. Plot the amplitude and phase response.

    Program

    clear;clc;

    choice = 0;

    while(choice ~= 5)

    clc;

    disp('**************MAIN MENU***************');disp('------chebyshev type-I Filter--------');

    disp('1: Low pass filter');

    disp('2: High pass filter');

    disp('3: Band pass filter');disp('4: Band reject filter');

    disp('5: Exit');

    choice = input('Your Choice :');if(choice == 5)

    break;

    end

    format long;

    rp=input('enter the passband ripple=');rs=input('enter the stopband ripple=');

    wp=input('enter the passband freq=');

    ws=input('enter the stopband freq=');

    fs=input('enter the sampling freq=');w1=2*wp/fs;

    w2=2*ws/fs;

    switch(choice)

    case 1

    [n,wn]=cheb1ord(w1,w2,rp,rs);

    [b,a]=cheby1(n,rp,wn);

    case 2

  • 8/4/2019 DSP Practicals

    27/35

    [n,wn]=cheb1ord(w1,w2,rp,rs);

    [b,a]=cheby1(n,rp,wn,'high');

    case 3

    [n]=cheb1ord(w1,w2,rp,rs);

    wn=[w1 w2];

    [b,a]=cheby1(n,rp,wn,'bandpass');

    case 4

    [n]=cheb1ord(w1,w2,rp,rs);wn=[w1 w2];

    [b,a]=cheby1(n,rp,wn,'stop');

    end

    w=0:.01:pi;[h,om]=freqz(b,a,w);

    m=20*log10(abs(h));

    an=angle(h);

    subplot(2,1,1);plot(om/pi,m);

    ylabel('Gain in db-->');

    xlabel('(a) Normalized frequency-->');subplot(2,1,2);

    plot(om/pi,an);

    xlabel('(b) Normalized frequency-->');ylabel('phase in radians-->');

    end

    Input

    The given sample input for all the filters i.e. LP, HP, BP, BR in this program are:

    1) Chebyshev Type-I Low Pass filter (LP):

    a) Passband ripple=0.2

    b) Stopband ripple=45c) Passband frequency=1300

    d) Stopband frequency=1500

    e) Sampling frequency=10000

  • 8/4/2019 DSP Practicals

    28/35

    2) Chebyshev Type-I High Pass filter (HP):

    a) Passband ripple=0.3b) Stopband ripple=60

    c) Passband frequency=1500

    d) Stopband frequency=2000e) Sampling frequency=9000

    3) Chebyshev Type-I Band Pass filter (BP):

    a) Passband ripple=0.4

    b) Stopband ripple=35

    c) Passband frequency=2000d) Stopband frequency=2500

    e) Sampling frequency=10000

    4) Chebyshev Type-I Band Reject filter (BR):

    a) Passband ripple=0.25b) Stopband ripple=40

    c) Passband frequency=2500

    d) Stopband frequency=2750

    e) Sampling frequency=7000

    Output

    1) Chebyshev Type-I Low Pass filter (LP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-600

    -400

    -200

    0

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradians-->

  • 8/4/2019 DSP Practicals

    29/35

    2) Chebyshev Type-I High Pass filter (HP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400

    -300

    -200

    -100

    0

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinrad

    ians-->

    3) Chebyshev Type-I Band pass filter (BP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-600

    -400

    -200

    0

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradians-->

  • 8/4/2019 DSP Practicals

    30/35

    4) Chebyshev Type-I Band Reject filter (BR):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-150

    -100

    -50

    0

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinrad

    ians-->

    Conclusion

    Thus we have obtained the filter design method for Chebyshev Type-I filter for all types

    of filters viz. LP, HP, BP and BR.

  • 8/4/2019 DSP Practicals

    31/35

    10. AimWrite a program to design digital Chebyshev Type-II filters [ LP, HP, BP,

    BR] for the following specifications

    a) Pass band ripple

    b) Pass band frequency

    c) Stop band ripple

    d) Stop band frequencye) Sampling frequency

    Use cheb2ord, cheby2 and freqz functions. Plot the amplitude and phase response.

    Program

    clear;clc;

    choice = 0;

    while(choice ~= 5)

    clc;disp('**************MAIN MENU***************');

    disp('-----Chebyshev type-II Filter--------');disp('1: Low pass filter');

    disp('2: High pass filter');

    disp('3: Band pass filter');

    disp('4: Band reject filter');disp('5: Exit');

    choice = input('Your Choice :');

    if(choice == 5)break;

    end

    format long;

    rp=input('enter the passband ripple=');

    rs=input('enter the stopband riple=');wp=input('enter the passband freq=');

    ws=input('enter the stopband freq=');

    fs=input('enter the sampling freq=');

    w1=2*wp/fs;w2=2*ws/fs;

    switch(choice)case 1

    [n,wn]=cheb2ord(w1,w2,rp,rs);[b,a]=cheby2(n,rs,wn);

    case 2

  • 8/4/2019 DSP Practicals

    32/35

    [n,wn]=cheb2ord(w1,w2,rp,rs);

    [b,a]=cheby2(n,rs,wn,'high');

    case 3

    [n]=cheb2ord(w1,w2,rp,rs);wn=[w1 w2];

    [b,a]=cheby2(n,rs,wn,'bandpass');

    case 4

    [n]=cheb2ord(w1,w2,rp,rs);

    wn=[w1 w2];[b,a]=cheby2(n,rs,wn,'stop');

    end

    w=0:.01/pi:pi;

    [h,om]=freqz(b,a,w);m=20*log10(abs(h));

    an=angle(h);

    subplot(2,1,1);

    plot(om/pi,m);ylabel('Gain in db-->');

    xlabel('(a) Normalized frequency-->');

    subplot(2,1,2);plot(om/pi,an);

    xlabel('(b) Normalized frequency-->');

    ylabel('phase in radians-->');

    end

    Input

    The given sample input for all the filters i.e. LP, HP, BP, BR in this program are:

    1) Chebyshev Type-II Low Pass filter (LP):

    a) Passband ripple=0.35

    b) Stopband ripple=35

    c) Passband frequency=1500d) Stopband frequency=2000

    e) Sampling frequency=8000

    2) Chebyshev Type-II High Pass filter (HP):

  • 8/4/2019 DSP Practicals

    33/35

    a) Passband ripple=0.25

    b) Stopband ripple=40

    c) Passband frequency=1400d) Stopband frequency=1800

    e) Sampling frequency=7000

    3) Chebyshev Type-II Band Pass filter (BP):

    a) Passband ripple=0.4b) Stopband ripple=40

    c) Passband frequency=1400

    d) Stopband frequency=2000

    e) Sampling frequency=9000

    4) Chebyshev Type-II Band Reject filter (BR):

    a) Passband ripple=0.3b) Stopband ripple=46

    c) Passband frequency=1400d) Stopband frequency=2000

    e) Sampling frequency=8000

    Output

    1) Chebyshev Type-II Low Pass Filter (LP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradians

    -->

  • 8/4/2019 DSP Practicals

    34/35

    2) Chebyshev Type-II High Pass filter (HP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    Gainind

    b-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradians-->

    3) Chebyshev Type-II Band pass filter (BP):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-400

    -200

    0

    200

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradian

    s-->

  • 8/4/2019 DSP Practicals

    35/35

    4) Chebyshev Type-II Band Reject filter (BR):

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

    -50

    0

    50

    Gainindb-->

    (a) Normalized frequency-->

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    (b) Normalized frequency-->

    phaseinradian

    s-->

    Conclusion

    Thus we have obtained the filter design method for Chebyshev Type-II filter for all types

    of filters viz. LP, HP, BP and BR.