DIGITAL SIGNAL PROCESSING LAB RECORD                                  Experiment: 1                  AM, FM and PWM using ...
DIGITAL SIGNAL PROCESSING LAB RECORDFrequency Modulated Waveclc;clear all;close all;a=input(Amplitude:);fc=input(Carrier f...
DIGITAL SIGNAL PROCESSING LAB RECORDPulse Width Modulated Waveclc;clear all;close all;fs=100;t=0:1/(5*fs):2;x=sawtooth(2*p...
DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTRESULTThe programs for AM, FM & PWM signals are implemented in MATLAB and the ou...
DIGITAL SIGNAL PROCESSING LAB RECORD                                   Experiment: 2                              Linear C...
DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTFirst sequence:[1 2 3 4]Second sequence:[4 3 2 1]RESULTThe program for convoluti...
DIGITAL SIGNAL PROCESSING LAB RECORD                                        Experiment: 3                                 ...
DIGITAL SIGNAL PROCESSING LAB RECORDtitle(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FI...
DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTEnter passband ripple:0.05Enter stopband ripple:0.04Enter passband frequency:150...
DIGITAL SIGNAL PROCESSING LAB RECORD                                      Experiment: 4                           Butterwo...
DIGITAL SIGNAL PROCESSING LAB RECORDxlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50En...
DIGITAL SIGNAL PROCESSING LAB RECORD[b,a]=butter(n,wn,high);w=0:0.01:pi;[h,om]=freqz(b,a,w);m=20*log10(abs(h));an=angle(h)...
DIGITAL SIGNAL PROCESSING LAB RECORDBand Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Ente...
DIGITAL SIGNAL PROCESSING LAB RECORDtitle(IIR Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(...
DIGITAL SIGNAL PROCESSING LAB RECORDwp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe IIR Butterworth filters are designed using MATLAB and the output waveforms a...
DIGITAL SIGNAL PROCESSING LAB RECORDws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=...
DIGITAL SIGNAL PROCESSING LAB RECORDHigh Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Ente...
DIGITAL SIGNAL PROCESSING LAB RECORDtitle(Chebyshev Type 1 High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised freque...
DIGITAL SIGNAL PROCESSING LAB RECORDrs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter st...
DIGITAL SIGNAL PROCESSING LAB RECORDBand Stop Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Ente...
DIGITAL SIGNAL PROCESSING LAB RECORDan=angle(h);subplot(2,1,1);plot(om/pi,m);title(Chebyshev Type 1 Band Stop Filter);ylab...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe Chebyshev Type 1 filters are implemented using MATLAB p waveforms areobtaine...
DIGITAL SIGNAL PROCESSING LAB RECORDw2=2*ws/fs;[n,wn]=cheb2ord(w1,w2,rp,rs);[b,a]=cheby2(n,rp,wn);w=0:0.01:pi;[h,om]=freqz...
DIGITAL SIGNAL PROCESSING LAB RECORDHigh Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Ente...
DIGITAL SIGNAL PROCESSING LAB RECORDtitle(Chebyshev Type 2 High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised freque...
DIGITAL SIGNAL PROCESSING LAB RECORDrs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter st...
DIGITAL SIGNAL PROCESSING LAB RECORDBand Stop Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Ente...
DIGITAL SIGNAL PROCESSING LAB RECORDm=20*log10(abs(h));an=angle(h);subplot(2,1,1);plot(om/pi,m);title(Chebyshev Type 2 Ban...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe Chebyshev Type 2 filters are implemented using MATLAB & the output waveforms...
DIGITAL SIGNAL PROCESSING LAB RECORDwp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;dem=14.6*(fs-fp)/f;n=ceil(num/dem);n...
DIGITAL SIGNAL PROCESSING LAB RECORD[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Fi...
DIGITAL SIGNAL PROCESSING LAB RECORD.PROGRAM-HAMMING WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=inp...
DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;d...
DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);tit...
DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAM-KAISER WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=input...
DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);beta=input(Enter beta value:);wp=2*fp/f;ws=2*fs/f;n...
DIGITAL SIGNAL PROCESSING LAB RECORDwn=[wp,ws];b=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(...
DIGITAL SIGNAL PROCESSING LAB RECORDEnter beta value:5.8PROGRAM-HANNING WINDOWclc;clear all;close all;rp=input(Enter passb...
DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;d...
DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);tit...
DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAM-BLACKMAN WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=inp...
DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;d...
DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);tit...
DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAM-BARTLETT WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=inp...
DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;d...
DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);tit...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTFIR filters using Rectangular, Hamming, Kaiser, Hanning, Blackman & Bartlett win...
DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAMclc;clear all;close all;a=input(First sequence:);b=input(Second sequence:);d=le...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe circular convolution of 2 sequences is implemented using MATLAB & resultings...
DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo write a program in MATLAB for the linear convolution of 2 sequences using circul...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe linear convolution of 2 sequences using circular convolution is implemented ...
DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo generate discrete time unit step, sinusoidal, exponential & addition sequences.P...
DIGITAL SIGNAL PROCESSING LAB RECORDstem(n,x3);title(Added sequence);xlabel(Time);ylabel(Amplitude);OUTPUTEnter length:21R...
DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo find Discrete Fourier Transform (DFT) & Inverse Discrete Fourier Transform (IDFT...
DIGITAL SIGNAL PROCESSING LAB RECORDEnter samples:3RESULTThe DFT & IDFT of a sequence is obtained in MATLAB & output wavef...
DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo compute the linear convolution of 2 sequences using overlap-save method.PROGRAMc...
DIGITAL SIGNAL PROCESSING LAB RECORDEnter input sequence:[1 2 3 4 5]Enter impulse sequence:[3 2 1]RESULTThe linear convolu...
DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo compute the linear convolution of 2 sequences using overlap-add method.PROGRAMcl...
DIGITAL SIGNAL PROCESSING LAB RECORD       temp2=j+1;       temp3=yp(temp1,temp2)+yp(i,j);       yp(temp1,temp2)=yp(i,j); ...
DIGITAL SIGNAL PROCESSING LAB RECORDend;y=x*H;OUTPUTColumns 1 through 13   1   4    4   3   8    5   -2   -6    -6   -1   ...
DIGITAL SIGNAL PROCESSING LAB RECORDTo generate Gaussian, Poisson & random distributions using MATLAB.PROGRAMclc;clear all...
DIGITAL SIGNAL PROCESSING LAB RECORDEnter value of lambda:0.05Size of first array:10Size of second array:20Enter value:21R...
DIGITAL SIGNAL PROCESSING LAB RECORDTo obtain a filter using frequency sampling method.PROGRAMclc;clear all;close all;N=33...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe filter is obtained using frequency sampling method in MATLAB.Dept. of Electr...
DIGITAL SIGNAL PROCESSING LAB RECORD                                       Experiment: 16                                 ...
DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTEnter length of sinusoidal signal:25Upsampling factor:2Input signal frequency:10...
DIGITAL SIGNAL PROCESSING LAB RECORD                                       Experiment: 17                               Do...
DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTEnter length of sinusoidal signal:25Downsampling factor:3Input signal frequency:...
DIGITAL SIGNAL PROCESSING LAB RECORD                                        Experiment: 18                                ...
DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe required random sequence is obtained using MATLAB.Dept. of Electronics & Com...
Upcoming SlideShare
Loading in...5
×

Matlab fair-record-model

1,270

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,270
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
87
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Matlab fair-record-model"

  1. 1. DIGITAL SIGNAL PROCESSING LAB RECORD Experiment: 1 AM, FM and PWM using MATLABAIMTo implement a program in MATLAB to generate Amplitude Modulated (AM),Frequency Modulated (FM) & Pulse Width Modulated (PWM) waveforms.PROGRAMAmplitude Modulated Waveclc;clear all;close all;t=0:0.0001:0.015;m=input(Modulation Index:);fm=input(Signal frequency:);fc=input(Carrier frequency:);x=sin(2*pi*fm*t);y=sin(2*pi*fc*t);e=(1+(m.*x)).*y;plot(e);title(Amplitude Modulation);xlabel(Time);ylabel(Amplitude);OUTPUTModulation Index:0.5Signal frequency:100Carrier frequency:1000Dept. of Electronics & Communication Engg. Page No: 1SCT College of EngineeringPappanamcode-18
  2. 2. DIGITAL SIGNAL PROCESSING LAB RECORDFrequency Modulated Waveclc;clear all;close all;a=input(Amplitude:);fc=input(Carrier frequency:);fm=input(Signal frequency:);m=input(Modulation index:);n=0:0.001:0.2;y=a*sin(2*pi*fc*n-(m*cos(2*pi*fm*n)));plot(n,y);title(Frequency Modulation);xlabel(Time);ylabel(Amplitude);OUTPUTAmplitude:1Carrier frequency:100Signal frequency:10Modulation index:5Dept. of Electronics & Communication Engg. Page No: 2SCT College of EngineeringPappanamcode-18
  3. 3. DIGITAL SIGNAL PROCESSING LAB RECORDPulse Width Modulated Waveclc;clear all;close all;fs=100;t=0:1/(5*fs):2;x=sawtooth(2*pi*20*t);m=0.75*sin(2*pi*t);k=length(x);for i=1:k if (m(i)>=x(i)) pwm(i)=1; else if (m(i)<x(i)) pwm(i)=0; end; end;end;plot(t,pwm,t,m);axis([0,-1,-2,2]);title(Pulse Width Modulation);xlabel(Time);ylabel(Amplitude);Dept. of Electronics & Communication Engg. Page No: 3SCT College of EngineeringPappanamcode-18
  4. 4. DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTRESULTThe programs for AM, FM & PWM signals are implemented in MATLAB and the outputwaveforms are generated.Dept. of Electronics & Communication Engg. Page No: 4SCT College of EngineeringPappanamcode-18
  5. 5. DIGITAL SIGNAL PROCESSING LAB RECORD Experiment: 2 Linear ConvolutionAIMTo write a program in MATLAB for the linear convolution of 2 sequences.PROGRAMclc;clear all;close all;a=input(First sequence:);b=input(Second sequence:);c=fliplr(b);d=length(a);e=length(b);f=[zeros(1,e-1),a,zeros(1,e)];g=0;i=d+e-1;for h=0:(d+e-1) j=[zeros(1,g),c,zeros(1,i)]; k=sum(f.*j); con(g+1)=k; g=g+1; i=i-1;end;m=0:d+e-1;stem(m,con);title(Convlouted sequence);xlabel(Time);ylabel(Amplitude);Dept. of Electronics & Communication Engg. Page No: 5SCT College of EngineeringPappanamcode-18
  6. 6. DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTFirst sequence:[1 2 3 4]Second sequence:[4 3 2 1]RESULTThe program for convolution of 2 sequences is implemented using MATLAB and theresulting sequence is graphically generated.Dept. of Electronics & Communication Engg. Page No: 6SCT College of EngineeringPappanamcode-18
  7. 7. DIGITAL SIGNAL PROCESSING LAB RECORD Experiment: 3 FIR FiltersAIMTo write a program in MATLAB for implementing FIR filters.PROGRAMclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);fp=input(Enter passband frequency:);fs=input(Enter stopband frequency:);f=input(Enter sampling frequency:);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=boxcar(n1);%LOW PASS FILTERb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);Dept. of Electronics & Communication Engg. Page No: 7SCT College of EngineeringPappanamcode-18
  8. 8. DIGITAL SIGNAL PROCESSING LAB RECORDtitle(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FILTERb=fir1(n,wp,high,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title(High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND PASS FILTERwn=[wp,ws];b=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND STOP FILTERb=fir1(n,wn,stop,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title(Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);Dept. of Electronics & Communication Engg. Page No: 8SCT College of EngineeringPappanamcode-18
  9. 9. DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTEnter passband ripple:0.05Enter stopband ripple:0.04Enter passband frequency:1500Enter stopband frequency:2000Enter sampling frequency:9000RESULTThe program for FIR filters are implemented using MATLAB and the correspondingfrequency responses are obtained.Dept. of Electronics & Communication Engg. Page No: 9SCT College of EngineeringPappanamcode-18
  10. 10. DIGITAL SIGNAL PROCESSING LAB RECORD Experiment: 4 Butterworth IIR FiltersAIMTo design & simulate Butterworth IIR filters using MATLAB.PROGRAMLow Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(n,wn);w=0: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);title(IIR Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));Dept. of Electronics & Communication Engg. Page No: 10SCT College of EngineeringPappanamcode-18
  11. 11. DIGITAL SIGNAL PROCESSING LAB RECORDxlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:200Enter stopband frequency:400Enter passband frequency:1000High Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=buttord(w1,w2,rp,rs);Dept. of Electronics & Communication Engg. Page No: 11SCT College of EngineeringPappanamcode-18
  12. 12. DIGITAL SIGNAL PROCESSING LAB RECORD[b,a]=butter(n,wn,high);w=0: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);title(IIR High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:1200Enter stopband frequency:1000Enter passband frequency:4000Dept. of Electronics & Communication Engg. Page No: 12SCT College of EngineeringPappanamcode-18
  13. 13. DIGITAL SIGNAL PROCESSING LAB RECORDBand Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(n,wn);w=0: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);Dept. of Electronics & Communication Engg. Page No: 13SCT College of EngineeringPappanamcode-18
  14. 14. DIGITAL SIGNAL PROCESSING LAB RECORDtitle(IIR Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.4Enter stopband ripple:50Enter passband frequency:[800 1200]Enter stopband frequency:[500 1500]Enter passband frequency:4000Band Stop Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);Dept. of Electronics & Communication Engg. Page No: 14SCT College of EngineeringPappanamcode-18
  15. 15. DIGITAL SIGNAL PROCESSING LAB RECORDwp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(n,wn,stop);w=0: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);title(IIR Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.4Enter stopband ripple:50Enter passband frequency:[800 1500]Enter stopband frequency:[1000 1200]Enter passband frequency:4000Dept. of Electronics & Communication Engg. Page No: 15SCT College of EngineeringPappanamcode-18
  16. 16. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe IIR Butterworth filters are designed using MATLAB and the output waveforms areobtained. Experiment: 5 Chebyshev Type 1 FiltersAIMTo design & simulate Chebyshev Type 1 filters using MATLAB.PROGRAMLow Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);Dept. of Electronics & Communication Engg. Page No: 16SCT College of EngineeringPappanamcode-18
  17. 17. DIGITAL SIGNAL PROCESSING LAB RECORDws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=cheb1ord(w1,w2,rp,rs);[b,a]=cheby1(n,rp,wn);w=0: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);title(Chebyshev Type 1 Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:1000Enter stopband frequency:1500Enter passband frequency:4000Dept. of Electronics & Communication Engg. Page No: 17SCT College of EngineeringPappanamcode-18
  18. 18. DIGITAL SIGNAL PROCESSING LAB RECORDHigh Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=cheb1ord(w1,w2,rp,rs);[b,a]=cheby1(n,rp,wn,high);w=0: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);Dept. of Electronics & Communication Engg. Page No: 18SCT College of EngineeringPappanamcode-18
  19. 19. DIGITAL SIGNAL PROCESSING LAB RECORDtitle(Chebyshev Type 1 High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:1500Enter stopband frequency:1000Enter passband frequency:5000Band Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);Dept. of Electronics & Communication Engg. Page No: 19SCT College of EngineeringPappanamcode-18
  20. 20. DIGITAL SIGNAL PROCESSING LAB RECORDrs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=cheb1ord(w1,w2,rp,rs);[b,a]=cheby1(n,rp,wn);w=0: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);title(Chebyshev Type 1 Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:[1000 1200]Enter stopband frequency:[800 1500]Enter passband frequency:4500Dept. of Electronics & Communication Engg. Page No: 20SCT College of EngineeringPappanamcode-18
  21. 21. DIGITAL SIGNAL PROCESSING LAB RECORDBand Stop Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=cheb1ord(w1,w2,rp,rs);[b,a]=cheby1(n,rp,wn,stop);w=0:0.01:pi;[h,om]=freqz(b,a,w);m=20*log10(abs(h));Dept. of Electronics & Communication Engg. Page No: 21SCT College of EngineeringPappanamcode-18
  22. 22. DIGITAL SIGNAL PROCESSING LAB RECORDan=angle(h);subplot(2,1,1);plot(om/pi,m);title(Chebyshev Type 1 Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:[1000 1200]Enter stopband frequency:[800 1500]Enter passband frequency:4500Dept. of Electronics & Communication Engg. Page No: 22SCT College of EngineeringPappanamcode-18
  23. 23. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe Chebyshev Type 1 filters are implemented using MATLAB p waveforms areobtained. Experiment: 6 Chebyshev type 2 FiltersAIMTo design & simulate Chebyshev Type 2 filters using MATLAB.PROGRAMLow Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;Dept. of Electronics & Communication Engg. Page No: 23SCT College of EngineeringPappanamcode-18
  24. 24. DIGITAL SIGNAL PROCESSING LAB RECORDw2=2*ws/fs;[n,wn]=cheb2ord(w1,w2,rp,rs);[b,a]=cheby2(n,rp,wn);w=0: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);title(Chebyshev Type 2 Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:1000Enter stopband frequency:1500Enter passband frequency:4000Dept. of Electronics & Communication Engg. Page No: 24SCT College of EngineeringPappanamcode-18
  25. 25. DIGITAL SIGNAL PROCESSING LAB RECORDHigh Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=cheb2ord(w1,w2,rp,rs);[b,a]=cheby2(n,rp,wn,high);w=0: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);Dept. of Electronics & Communication Engg. Page No: 25SCT College of EngineeringPappanamcode-18
  26. 26. DIGITAL SIGNAL PROCESSING LAB RECORDtitle(Chebyshev Type 2 High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:1000Enter stopband frequency:800Enter passband frequency:4500Band Pass Filterclc;clear all;close all;rp=input(Enter passband ripple:);Dept. of Electronics & Communication Engg. Page No: 26SCT College of EngineeringPappanamcode-18
  27. 27. DIGITAL SIGNAL PROCESSING LAB RECORDrs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=cheb2ord(w1,w2,rp,rs);[b,a]=cheby2(n,rp,wn);w=0: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);title(Chebyshev Type 2 Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:[800 1500]Enter stopband frequency:[1000 1200]Enter passband frequency:4500Dept. of Electronics & Communication Engg. Page No: 27SCT College of EngineeringPappanamcode-18
  28. 28. DIGITAL SIGNAL PROCESSING LAB RECORDBand Stop Filterclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);wp=input(Enter passband frequency:);ws=input(Enter stopband frequency:);fs=input(Enter passband frequency:);w1=2*wp/fs;w2=2*ws/fs;[n,wn]=cheb2ord(w1,w2,rp,rs);[b,a]=cheby2(n,rp,wn,stop);w=0:0.01:pi;[h,om]=freqz(b,a,w);Dept. of Electronics & Communication Engg. Page No: 28SCT College of EngineeringPappanamcode-18
  29. 29. DIGITAL SIGNAL PROCESSING LAB RECORDm=20*log10(abs(h));an=angle(h);subplot(2,1,1);plot(om/pi,m);title(Chebyshev Type 2 Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised frequency);subplot(2,1,2);plot(om/pi,an);ylabel(Phase (radians));xlabel(Normalised frequency);OUTPUTEnter passband ripple:0.5Enter stopband ripple:50Enter passband frequency:[800 1500]Enter stopband frequency:[1000 1200]Enter passband frequency:4500Dept. of Electronics & Communication Engg. Page No: 29SCT College of EngineeringPappanamcode-18
  30. 30. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe Chebyshev Type 2 filters are implemented using MATLAB & the output waveformsare obtained. Experiment: 7 FIR Filters Using Window MethodsAIMTo design & simulate FIR filters using various windows such as rectangular, Hamming,Kaiser, Hanning, Blackman & Bartlett windows in MATLAB.PROGRAM- RECTANGULAR WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);fp=input(Enter passband frequency:);fs=input(Enter stopband frequency:);f=input(Enter sampling frequency:);Dept. of Electronics & Communication Engg. Page No: 30SCT College of EngineeringPappanamcode-18
  31. 31. DIGITAL SIGNAL PROCESSING LAB RECORDwp=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=rectwin(n1);%LOW PASS FILTERb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);title(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FILTERb=fir1(n,wp,high,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title(High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND PASS FILTERwn=[wp,ws];b=fir1(n,wn,y);Dept. of Electronics & Communication Engg. Page No: 31SCT College of EngineeringPappanamcode-18
  32. 32. DIGITAL SIGNAL PROCESSING LAB RECORD[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND STOP FILTERb=fir1(n,wn,stop,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title(Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);OUTPUTEnter passband ripple:0.05Enter stopband ripple:0.04Enter passband frequency:1500Enter stopband frequency:2000Enter sampling frequency:9000Dept. of Electronics & Communication Engg. Page No: 32SCT College of EngineeringPappanamcode-18
  33. 33. DIGITAL SIGNAL PROCESSING LAB RECORD.PROGRAM-HAMMING WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);fp=input(Enter passband frequency:);fs=input(Enter stopband frequency:);Dept. of Electronics & Communication Engg. Page No: 33SCT College of EngineeringPappanamcode-18
  34. 34. DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);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);%LOW PASS FILTERb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);title(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FILTERb=fir1(n,wp,high,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title(High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND PASS FILTERwn=[wp,ws];Dept. of Electronics & Communication Engg. Page No: 34SCT College of EngineeringPappanamcode-18
  35. 35. DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND STOP FILTERb=fir1(n,wn,stop,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title(Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);OUTPUTEnter passband ripple:0.02Enter stopband ripple:0.01Enter passband frequency:1200Enter stopband frequency:1700Enter sampling frequency:9000Dept. of Electronics & Communication Engg. Page No: 35SCT College of EngineeringPappanamcode-18
  36. 36. DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAM-KAISER WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);fp=input(Enter passband frequency:);fs=input(Enter stopband frequency:);Dept. of Electronics & Communication Engg. Page No: 36SCT College of EngineeringPappanamcode-18
  37. 37. DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);beta=input(Enter beta value:);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=kaiser(n1,beta);%LOW PASS FILTERb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);title(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FILTERb=fir1(n,wp,high,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title(High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND PASS FILTERDept. of Electronics & Communication Engg. Page No: 37SCT College of EngineeringPappanamcode-18
  38. 38. DIGITAL SIGNAL PROCESSING LAB RECORDwn=[wp,ws];b=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND STOP FILTERb=fir1(n,wn,stop,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title(Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);OUTPUTEnter passband ripple:0.02Enter stopband ripple:0.01Enter passband frequency:1000Enter stopband frequency:1500Enter sampling frequency:10000Dept. of Electronics & Communication Engg. Page No: 38SCT College of EngineeringPappanamcode-18
  39. 39. DIGITAL SIGNAL PROCESSING LAB RECORDEnter beta value:5.8PROGRAM-HANNING WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);fp=input(Enter passband frequency:);fs=input(Enter stopband frequency:);Dept. of Electronics & Communication Engg. Page No: 39SCT College of EngineeringPappanamcode-18
  40. 40. DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);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);%LOW PASS FILTERb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);title(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FILTERb=fir1(n,wp,high,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title(High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND PASS FILTERwn=[wp,ws];Dept. of Electronics & Communication Engg. Page No: 40SCT College of EngineeringPappanamcode-18
  41. 41. DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND STOP FILTERb=fir1(n,wn,stop,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title(Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);OUTPUTEnter passband ripple:0.03Enter stopband ripple:0.01Enter passband frequency:1400Enter stopband frequency:2000Enter sampling frequency:8000Dept. of Electronics & Communication Engg. Page No: 41SCT College of EngineeringPappanamcode-18
  42. 42. DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAM-BLACKMAN WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);fp=input(Enter passband frequency:);fs=input(Enter stopband frequency:);Dept. of Electronics & Communication Engg. Page No: 42SCT College of EngineeringPappanamcode-18
  43. 43. DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);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=blackman(n1);%LOW PASS FILTERb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);title(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FILTERb=fir1(n,wp,high,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title(High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND PASS FILTERwn=[wp,ws];Dept. of Electronics & Communication Engg. Page No: 43SCT College of EngineeringPappanamcode-18
  44. 44. DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND STOP FILTERb=fir1(n,wn,stop,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title(Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);OUTPUTEnter passband ripple:0.03Enter stopband ripple:0.01Enter passband frequency:2000Enter stopband frequency:2500Enter sampling frequency:7000Dept. of Electronics & Communication Engg. Page No: 44SCT College of EngineeringPappanamcode-18
  45. 45. DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAM-BARTLETT WINDOWclc;clear all;close all;rp=input(Enter passband ripple:);rs=input(Enter stopband ripple:);fp=input(Enter passband frequency:);fs=input(Enter stopband frequency:);Dept. of Electronics & Communication Engg. Page No: 45SCT College of EngineeringPappanamcode-18
  46. 46. DIGITAL SIGNAL PROCESSING LAB RECORDf=input(Enter sampling frequency:);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=bartlett(n1);%LOW PASS FILTERb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);title(Low Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%HIGH PASS FILTERb=fir1(n,wp,high,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title(High Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND PASS FILTERwn=[wp,ws];Dept. of Electronics & Communication Engg. Page No: 46SCT College of EngineeringPappanamcode-18
  47. 47. DIGITAL SIGNAL PROCESSING LAB RECORDb=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title(Band Pass Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);%BAND STOP FILTERb=fir1(n,wn,stop,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title(Band Stop Filter);ylabel(Gain (in dB));xlabel(Normalised Frequency);OUTPUTEnter passband ripple:0.04Enter stopband ripple:0.02Enter passband frequency:1500Enter stopband frequency:2000Enter sampling frequency:8000Dept. of Electronics & Communication Engg. Page No: 47SCT College of EngineeringPappanamcode-18
  48. 48. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTFIR filters using Rectangular, Hamming, Kaiser, Hanning, Blackman & Bartlett windowsare implemented in MATLAB & output waveforms are obtained. Experiment: 8 Circular ConvolutionAIMTo write a program in MATLAB for the circular convolution of 2 sequences.Dept. of Electronics & Communication Engg. Page No: 48SCT College of EngineeringPappanamcode-18
  49. 49. DIGITAL SIGNAL PROCESSING LAB RECORDPROGRAMclc;clear all;close all;a=input(First sequence:);b=input(Second sequence:);d=length(a);e=length(b);if(d>e) f=a; g=[b,zeros(1,d-e)];end;if(d<e) f=[a,zeros(1,e-d)]; g=b;end;n=0;i=length(f)-1;for h=0:i k=sum(f.*g); con(n+1)=k; n=n+1; g=circshift(g,[0 -1]);end;stem(con);title(Circular convoluted sequence:);xlabel(Time);ylabel(Amplitude);OUTPUTFirst sequence:[1 2 3]Second sequence:[5 4 3 2]Dept. of Electronics & Communication Engg. Page No: 49SCT College of EngineeringPappanamcode-18
  50. 50. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe circular convolution of 2 sequences is implemented using MATLAB & resultingsequence is graphically obtained. Experiment: 9 Linear Convolution Using Circular ConvolutionDept. of Electronics & Communication Engg. Page No: 50SCT College of EngineeringPappanamcode-18
  51. 51. DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo write a program in MATLAB for the linear convolution of 2 sequences using circularconvolution.PROGRAMclc;clear all;close all;x=input(Enter first sequence:);h=input(Enter second sequence:);n1=length(x);n2=length(h);N=n1+n2-1;x=[x zeros(1,n2-1)];h=[h zeros(1,n1-1)];for n=0:N-1 y(n+1)=0; for i=0:N-1 j=mod(n-i,N); y(n+1)=y(n+1)+x(i+1)*h(j+1); end;end;disp(y);stem(y);title(Linear convolution using circular convolution);ylabel(Amplitude);xlabel(Time);OUTPUTEnter first sequence:[1 2 3 4]Enter second sequence:[4 1 4] 4 9 18 27 16 16Dept. of Electronics & Communication Engg. Page No: 51SCT College of EngineeringPappanamcode-18
  52. 52. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe linear convolution of 2 sequences using circular convolution is implemented usingMATLAB & resulting sequence is graphically obtained. Experiment: 10 Discrete Time SequenceDept. of Electronics & Communication Engg. Page No: 52SCT College of EngineeringPappanamcode-18
  53. 53. DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo generate discrete time unit step, sinusoidal, exponential & addition sequences.PROGRAMclc;clear all;close all;N=input(Enter length:);%UNIT STEP SEQUENCEx=ones(1,N);n=0:1:N-1;subplot(2,2,1);stem(n,x);title(Unit step sequence);xlabel(Time);ylabel(Amplitude);%SINUSOIDAL SEQUENCEx1=cos(.2*pi*n);subplot(2,2,2);stem(n,x1);title(Sinusoidal sequence);xlabel(Time);ylabel(Amplitude);%EXPONENTIAL SEQUENCEx2=exp(n);subplot(2,2,3);stem(n,x2);title(Exponential sequence);xlabel(Time);ylabel(Amplitude);%ADDITION OF 2 SINUSOIDAL SEQUENCESx3=sin(.1*pi*n)+sin(.2*pi*n);subplot(2,2,4);Dept. of Electronics & Communication Engg. Page No: 53SCT College of EngineeringPappanamcode-18
  54. 54. DIGITAL SIGNAL PROCESSING LAB RECORDstem(n,x3);title(Added sequence);xlabel(Time);ylabel(Amplitude);OUTPUTEnter length:21RESULTThe discrete time unit step, sinusoidal, exponential & addition of 2 sinusoidal sequencesare obtained in MATLAB. Experiment: 11 DFT & IDFTDept. of Electronics & Communication Engg. Page No: 54SCT College of EngineeringPappanamcode-18
  55. 55. DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo find Discrete Fourier Transform (DFT) & Inverse Discrete Fourier Transform (IDFT)of a sequence.PROGRAMclc;clear all;close all;x1=input(Enter sequence:);N=input(Enter samples:);xk=fft(x1)/N;n=0:1:length(xk)-1;subplot(2,2,2);stem(n,abs(xk));title(Magnitude Spectrum);subplot(2,2,3);stem(x1,angle(xk));title(Angle of Fourier Transform);xk1=ifft(xk)*N;subplot(2,2,4);stem(n,abs(xk1));title(Inverse of Fourier Transform);subplot(2,2,1);stem(n,x1);title(Input Signal);OUTPUTEnter sequence:[1 2 3 4]Dept. of Electronics & Communication Engg. Page No: 55SCT College of EngineeringPappanamcode-18
  56. 56. DIGITAL SIGNAL PROCESSING LAB RECORDEnter samples:3RESULTThe DFT & IDFT of a sequence is obtained in MATLAB & output waveforms areobtained. Experiment: 12Linear Convolution Using Overlap-Save MethodDept. of Electronics & Communication Engg. Page No: 56SCT College of EngineeringPappanamcode-18
  57. 57. DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo compute the linear convolution of 2 sequences using overlap-save method.PROGRAMclc; close all; clear all;x=input(Enter input sequence:);h=input(Enter impulse sequence:);N=4;if(N<length(h)) error(N must be >= length of h);end;Nx=length(x);m=length(h);m1=m-1;l=N-m1;x=[zeros(1,m-1),x,zeros(1,N-1)];h=[h,zeros(1,N-m)];k=floor((Nx+m1-1)/l);Y=zeros(k+1,N);for k=0:k xk=x(k*l+1:k*l+N); Y(k+1,:)=circonv(xk,h,N);end;Y=Y(:,m:N);y=(Y(:));stem(y);title(Overlap-Save Method);ylabel(Amplitude);xlabel(Time);OUTPUTDept. of Electronics & Communication Engg. Page No: 57SCT College of EngineeringPappanamcode-18
  58. 58. DIGITAL SIGNAL PROCESSING LAB RECORDEnter input sequence:[1 2 3 4 5]Enter impulse sequence:[3 2 1]RESULTThe linear convolution of 2 sequences is obtained using overlap-save method and outputwaveforms are obtained. Experiment: 13 Linear Convolution Using Overlap-Add MethodDept. of Electronics & Communication Engg. Page No: 58SCT College of EngineeringPappanamcode-18
  59. 59. DIGITAL SIGNAL PROCESSING LAB RECORDAIMTo compute the linear convolution of 2 sequences using overlap-add method.PROGRAMclc; close all; clear all;x=[1,2,-1,2,3,-2,-3,-1,1,1,2,-1];h=[1,2,1,1];N=4;y=ovrladd(x,h,N);disp(y);‘ovrladd’ functionfunction y= ovrladd(x,h,L);nx=length(x);m=length(h);m1=m-1;r=rem(nx,L);n=L+m1;x=[x,zeros(1,L-r)];h=[h,zeros(1,n-m)];K=floor(nx/L);Y=zeros(K+1,n);z=zeros(1,m1);for k=0:K xp=x(k*L+1:k*L+L); xk=[xp z]; y(k+1,:)=circonv(xk,h,n);end;yp=y;[x,y]=size(yp);for i=L+1:x for j=1:y-1 temp1=i-L;Dept. of Electronics & Communication Engg. Page No: 59SCT College of EngineeringPappanamcode-18
  60. 60. DIGITAL SIGNAL PROCESSING LAB RECORD temp2=j+1; temp3=yp(temp1,temp2)+yp(i,j); yp(temp1,temp2)=yp(i,j); yp(temp1,temp2)=temp3; end;end;z=1;for j=1:y for i=1:x if ((i<=L&j<=y-1)|(j==y)); ypnew(z)=yp(i,j); z=z+1; end; end;end;y=ypnew;‘circonv’ functionfunction[y]=circonv(x,h,N);n2=length(x);n3=length(h);x=[x,zeros(1,N-n2)];h=[h,zeros(1,N-n3)];m=[0:1:N-1];M=mod(-m,N);h=h(M+1);for n=1:1:N m=n-1; p=0:1:N-1; q=mod(p-m,N); hm=h(q+1); H(n,:)=hm;Dept. of Electronics & Communication Engg. Page No: 60SCT College of EngineeringPappanamcode-18
  61. 61. DIGITAL SIGNAL PROCESSING LAB RECORDend;y=x*H;OUTPUTColumns 1 through 13 1 4 4 3 8 5 -2 -6 -6 -1 4 5 1 Columns 14 through 19 1 -1 0 0 0 0RESULTThe linear convolution of 2 sequences is obtained using overlap-add method and outputsequence is obtained. Experiment: 14 DistributionsAIMDept. of Electronics & Communication Engg. Page No: 61SCT College of EngineeringPappanamcode-18
  62. 62. DIGITAL SIGNAL PROCESSING LAB RECORDTo generate Gaussian, Poisson & random distributions using MATLAB.PROGRAMclc;clear all;close all;%GAUSSIAN SIGNALx1=gauspuls(cutoff,50e3,.6,-40);x=-x1:1e-7:x1;y=gauspuls(x,50e3,.6);%POISSON SIGNALlambda=input(Enter value of lambda:);m=input(Size of first array:);n=input(Size of second array:);R=poissrnd(lambda,m,n);%RANDOM SIGNALp=input(Enter value:);d=rand(1,p);subplot(3,1,1);plot(x,y);xlabel(Time);ylabel(Amplitude);title(Gaussian distribution);subplot(3,1,2);plot(R);xlabel(Time);ylabel(Amplitude);title(Poisson distribution);subplot(3,1,3);plot(d);xlabel(Time);ylabel(Amplitude);title(Random distribution);OUTPUTDept. of Electronics & Communication Engg. Page No: 62SCT College of EngineeringPappanamcode-18
  63. 63. DIGITAL SIGNAL PROCESSING LAB RECORDEnter value of lambda:0.05Size of first array:10Size of second array:20Enter value:21RESULTThe Gaussian, Poisson & random distributions are implemented using MATLAB anfoutput waveforms are obtained. Experiment: 15 Frequency SamplingAIMDept. of Electronics & Communication Engg. Page No: 63SCT College of EngineeringPappanamcode-18
  64. 64. DIGITAL SIGNAL PROCESSING LAB RECORDTo obtain a filter using frequency sampling method.PROGRAMclc;clear all;close all;N=33;alpha=(N-1)/2;Hrk=[ones(1,9),zeros(1,16),ones(1,8)];k1=0:(N-1)/2;k2=(N+1)/2:N-1;theetak=[(-alpha*(2*pi)/N)*k1,(alpha*(2*pi)/N)*(N-k2)];Hk=Hrk.*(exp(i*theetak));hn=real(ifft(Hk,N));w=0:0.01:pi;H=freqz(hn,1,w);plot(w/pi,20*log10(abs(H)));hold on;Hrk=[ones(1,9),0.5,zeros(1,14),0.5,ones(1,8)];k1=0:(N-1)/2;k2=(N+1)/2:N-1;theetak=[(-alpha*(2*pi)/N)*k1,(alpha*(2*pi)/N)*(N-k2)];Hk=Hrk.*(exp(i*theetak));hn=real(ifft(Hk,N));w=0:0.01:pi;H=freqz(hn,1,w);plot(w/pi,20*log10(abs(H)),.);ylabel(Magnitude in dB);xlabel(Normalised frequency omega/pi);hold off;OUTPUTDept. of Electronics & Communication Engg. Page No: 64SCT College of EngineeringPappanamcode-18
  65. 65. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe filter is obtained using frequency sampling method in MATLAB.Dept. of Electronics & Communication Engg. Page No: 65SCT College of EngineeringPappanamcode-18
  66. 66. DIGITAL SIGNAL PROCESSING LAB RECORD Experiment: 16 Up-samplingAIMTo up-sample a given finite length sequence.PROGRAMN=input(Enter length of sinusoidal signal:);L=input(Upsampling factor:);fi=input(Input signal frequency:);n=0:N-1;x=sin(2*pi*fi*n);y=zeros(1,L*length(x));y([1:L:length(y)])=x;subplot(2,1,1);stem(n,x);title(Input sequence:);xlabel(Time n);ylabel(Amplitude);subplot(2,1,2);stem(n,y(1:length(x)));title([Output sequence, upsampling factor=,num2str(L)]);xlabel(Time n);ylabel(Amplitude);Dept. of Electronics & Communication Engg. Page No: 66SCT College of EngineeringPappanamcode-18
  67. 67. DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTEnter length of sinusoidal signal:25Upsampling factor:2Input signal frequency:100RESULTThe given sequence is up-sampled and the resulting waveforms are obtained.Dept. of Electronics & Communication Engg. Page No: 67SCT College of EngineeringPappanamcode-18
  68. 68. DIGITAL SIGNAL PROCESSING LAB RECORD Experiment: 17 Down-samplingAIMTo down-sample a given finite length sequence.PROGRAMclc;clear all;close all;N=input(Enter length of sinusoidal signal:);M=input(Downsampling factor:);fi=input(Input signal frequency:);n=0:N-1;m=0:N*M-1;x=sin(2*pi*fi*m);y=x([1:M:length(x)]);subplot(2,1,1);stem(n,x(1:N));title(Input sequence);ylabel(Amplitude);xlabel(Time);subplot(2,1,2);stem(n,y);title([Output sequence with downsampling factor ,num2str(M)]);ylabel(Amplitude);xlabel(Time);Dept. of Electronics & Communication Engg. Page No: 68SCT College of EngineeringPappanamcode-18
  69. 69. DIGITAL SIGNAL PROCESSING LAB RECORDOUTPUTEnter length of sinusoidal signal:25Downsampling factor:3Input signal frequency:100RESULTThe given sequence is down-sampled and the resulting waveforms are obtained.Dept. of Electronics & Communication Engg. Page No: 69SCT College of EngineeringPappanamcode-18
  70. 70. DIGITAL SIGNAL PROCESSING LAB RECORD Experiment: 18 Random SequenceAIMTo generate a random sequence in MATLAB.PROGRAMclc;clear all;close all;N=input(Enter length of random sequence:);y=linspace(1,N,N);x = 0+sqrt(1)*randn(1,N);disp(x);plot(y,x);title(Random Sequence);OUTPUTEnter length of random sequence:12 Columns 1 through 7 0.1139 1.0668 0.0593 -0.0956 -0.8323 0.2944 -1.3362 Columns 8 through 12 0.7143 1.6236 -0.6918 0.8580 1.2540Dept. of Electronics & Communication Engg. Page No: 70SCT College of EngineeringPappanamcode-18
  71. 71. DIGITAL SIGNAL PROCESSING LAB RECORDRESULTThe required random sequence is obtained using MATLAB.Dept. of Electronics & Communication Engg. Page No: 71SCT College of EngineeringPappanamcode-18

×