Sei sulla pagina 1di 42

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

DIGITAL SIGNAL PROCESSING COURSE CODE -EE -427-E

APEEJAY COLLEGE OF ENGINEERING, SOHNAPALWAL ROAD, VILLAGE SILANI, GURGAON, HARYANA PHONE:-0124-2013718/719/720

DIGITAL SIGNAL PROCESSING-LAB EXPERIMENTS:Design by the ECE deptt. Perform the experiments using MATLAB 1.To represent the basic signals (Unit Step, unit impulse, ramp, exponential, sine and cosine) 2. To develop program for discrete convolution. 3.To develop program for discrete correlation. 4.To understand Sampling theorm. 5. To find the effect of noise on the desired signal and to recover it back using filters 6. To design analog butterworth filter (low pass, high pass, band-pass, band stop). 7.To design analog Chebychev filter (low pass, high pass, band-pass, band stop). 8. To design digital Butterworth filter. 9.To design FIR filter using Bartlett window technique 10. To design FIR filter using Rectangular window technique

EXPERIMENT NUMBER : 1 AIM : To represent the basic signals(Unit Step, unit impulse, ramp, exponential, sine and cosine)

%UNIT STEP t=0:1:10; y= ones(1,11); subplot(3,2,1); stem(t,y); ylabel('amplitude'); xlabel('unitstep'); %UNIT IMPULSE t=-2:1:2; y1=[zeros(1,2),ones(1,1),zeros(1,2)]; subplot(3,2,2); stem(t,y1); ylabel('amplitude'); xlabel('unitimpulse'); %RAMP n1=input('enter length of ramp'); t=0:n1; subplot(3,2,3); stem(t,t); ylabel('amplitude'); xlabel('ramp'); %EXPONENTIAL n2=input('enter length of exponential'); t=0:n2; a=input('enter value of a'); y2=exp(a*t);

subplot(3,2,4); stem(t,y2); ylabel('amplitude'); xlabel('exponential'); %SINEWAVE t=0:0.01:pi; y3=sin(2*pi*t); subplot(3,2,5); plot(t,y3); ylabel('amplitude'); xlabel('sinewave'); %COSINEWAVE t=0:0.01:pi; y4=cos(2*pi*t); subplot(3,2,6); plot(t,y4); ylabel('amplitude'); xlabel('cosinewave');

EXPERIMENT NUMBER : 2 AIM : Convolution function x1=[1,2,3]; x2=[5,6] y1=xcorr(x1,x2); subplot(3,1,1) stem(x1) subplot(3,1,2) stem(x2) subplot(3,1,3) stem(y1); title('Convolution')

EXPERIMENT NUMBER : 3 AIM : Correlation function %autocorrelation x=[1,2,3]; y=xcorr(x,x); subplot(2,1,1) stem(y); title('Autocorrelation') x1=[1,2,3]; x2=[5,6] y1=xcorr(x1,x2); subplot(2,1,2) stem(y1); title('Crosscorrelation')

EXPERIMENT NUMBER : 4 Aim : Study of Sampling Theorem (test of Amplitude modulation) f1=1/128; fc=50/128; n=0:255; x=cos(2*pi*f1*n); xc=cos(2*pi*fc*n); xamp=x.*xc; subplot(3,1,1); plot(n,x); subplot(3,1,2); plot(n,xc); subplot(3,1,3); plot(n,xamp);

EXPERIMENT NUMBER : 5 Aim: To find the effect of noise on the desired signal and to recover it back using filters Fs=600; % Sample frequency of data [b,a] = fir1(8,10/(Fs/2),'low'); % 8th order FIR LP filter t=0:.001:.5; x=cos(2*pi*t*25); subplot(4,1,1); plot(x); y=randn(size(t)); subplot(4,1,2); plot(y); z=x+y; subplot(4,1,3); plot(z); w=filtfilt(b,a,z); subplot(4,1,4); plot(w);

EXPERIMENT NUMBER : 6a AIM : To design Analog Filters (Butterworth low pass Filters) N=1024; % NUMBER of data points Fs=500; % Sample frequency of data [b,a] = butter(8,90/(Fs/2),'s'); w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(om/pi,m); title('Butterworth low pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title('Butterworth low pass filtered data "phase response"'); xlabel('time'); ylabel('volts'); buttord

EXPERIMENT NUMBER : 6b AIM : To design Analog Filters (butterworth bandstop filter) Fs=500; % Sample frequency of data [b,a] = butter(8,[60/(Fs/2),90/(Fs/2)],'stop','s'); w=0:.01:pi; [h]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(w/pi,m); title('Butterworth band stop filtered data "amplitude response"'); subplot(2,1,2):plot(w/pi,an); title('Butterworth band stop filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 6C AIM : To design Analog Filters (butterworth HP filter) Fs=500; % Sample frequency of data [b,a] = butter(8,90/(Fs/2),'high','s'); w=0:.01:pi; [h]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(w/pi,m); title('Butterworth high pass filtered data "amplitude response"'); subplot(2,1,2):plot(w/pi,an); title('Butterworth high pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 6d AIM : To design Analog Filters (butterworth LP filter) Fs=500; % Sample frequency of data [b,a] = butter(8,90/(Fs/2),'s'); % 8th order butterworth LP filter w=0:.01:pi; [h]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(w/pi,m); title('Butterworth low pass filtered data "amplitude response"'); subplot(2,1,2):plot(w/pi,an); title('Butterworth low pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 7a AIM : To design Analog Filters (Chevychev band pass filter) Fs=500; % Sample frequency of data [b,a] = cheby1(8,0.5,[60/(Fs/2),90/(Fs/2)],'bandpass','s'); w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(om/pi,m); title('Chebychev type-1 band pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title(' Chebychev type-1 band pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 7b AIM : To design Analog Filters (Chevychev band stop filter) Fs=500; % Sample frequency of data [b,a] = cheby1(8,0.5,[60/(Fs/2),90/(Fs/2)],'stop','s'); w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(om/pi,m); title('Chebychev type-1 band stop filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title(' Chebychev type-1 band stop filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 7C AIM : To design Analog Filters (Chevychev highpass filter) Fs=500; % Sample frequency of data [b,a] = cheby1(8,0.5,90/(Fs/2),'high','s'); w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(om/pi,m); title('Chebychev type-1 high pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title(' Chebychev type-1 high pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 7d AIM : To design Analog Filters (Chevychev low pass filter) Fs=500; % Sample frequency of data [b,a] = cheby1(8,0.5,90/(Fs/2),'low','s'); w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,1,1):plot(om/pi,m); title('Chebychev type-1 low pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title(' Chebychev type-1 low pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 8a AIM : Digital butterworth bandstop filter Fs=500; % Sample frequency of data [b,a] = butter(8,[60/(Fs/2),90/(Fs/2)],'bandpass'); % 8th order digital butterworth bandstop filter 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); title('Butterworth digital band pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title('Butterworth digital band pass filtered data "phase response"'); xlabel('time'); ylabel('volts'); result1.

EXPERIMENT NUMBER : 8b AIM : Butterworth bandpass filter Fs=500; % Sample frequency of data [b,a] = butter(8,[60/(Fs/2),90/(Fs/2)],'bandpass'); % 8th order digital butterworth bandpass filter 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); title('Butterworth digital band pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title('Butterworth digital band pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 8C AIM : butterworth HP filter Fs=500; % Sample frequency of data [b,a] = butter(8,90/(Fs/2),'high'); % 8th order digital butterworth HP filter 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); title('Butterworth digital high pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title('Butterworth digital high pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 8d AIM : Butterworth digital LP filter Fs=500; [b,a] = butter(8,90/(Fs/2)); filter w=0:.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); % Sample frequency of data % 8th order butterworth digital LP

subplot(2,1,1):plot(om/pi,m); title('Butterworth digital low pass filtered data "amplitude response"'); subplot(2,1,2):plot(om/pi,an); title('Butterworth digital low pass filtered data "phase response"'); xlabel('time'); ylabel('volts');

EXPERIMENT NUMBER : 9 AIM : To design FIR filter using Bartlett window technique. fs=500; %low pass filter [b,a]=fir1(8,60/(fs/2),bartlett(9)); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); ylabel('gain in db ...>'); xlabel('(a) normalized frequency'); %high pass filter [b,a]=fir1(8,60/(fs/2),'high',bartlett(9)); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); ylabel('gain in db ...>'); xlabel('(b) normalized frequency'); %band pass filter [b,a]=fir1(8,[90/(fs/2),95/(fs/2)],'bandpass',bartlett(9)); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); ylabel('gain in db ...>'); xlabel('(c) normalized frequency'); %band stop filter [b,a]=fir1(8,[90/(fs/2),95/(fs/2)],'stop',bartlett(9)); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); ylabel('gain in db ...>'); xlabel('(d) normalized frequency');

EXPERIMENT NUMBER : 10 AIM : To design FIR filter using Rectangular window technique. fs=500; %low pass filter [b,a]=fir1(8,60/(fs/2),rectwin(9)); [h,o]=freqz(b,a,256); m=20*log10(abs(h)); an=angle(h); subplot(2,2,1):plot(o/pi,m); subplot(2,2,2):plot(o/pi,an); ylabel('gain in db ...>'); xlabel('(a) normalized frequency'); %high pass filter [b,a]=fir1(8,60/(fs/2),'high',rectwin(9)); [h,o]=freqz(b,a,256); m=20*log10(abs(h)); an=angle(h); subplot(2,2,3):plot(o/pi,an); ylabel('gain in db ...>'); xlabel('(b) normalized frequency'); %band pass filter [b,a]=fir1(8,[70/(fs/2),80/(fs/2)],'bandpass',rectwin(9)); [h,o]=freqz(b,a,256); m=20*log10(abs(h)); ylabel('gain in db ...>'); xlabel('(c) normalized frequency'); %band stop filter [b,a]=fir1(8,[70/(fs/2),80/(fs/2)],'stop',rectwin(9)); [h,o]=freqz(b,a,256); m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); ylabel('gain in db ...>'); xlabel('(d) normalized frequency');

Potrebbero piacerti anche