Vous êtes sur la page 1sur 24

(Affiliated to Kurukshetra University Kurukshetra) (Approved by AICTE, New Delhi)

Practical Report On
MATLAB (DIGITAL SIGNAL PROCESSING LAB)
ECE-490E

Submitted for partial fulfillment Of B. Tech. in

ELECTRONICS AND COMMUNICATION ENGINEERING

SUBMITTED TO: Er. Naresh Kumar H.O.D. ECE Department

SUBMITTED BY: Rashi Gupta 4309102 ECE 3rd Year

INDEX
S.NO. 1. EXPERIMENT NAME DATE PAGE NO. SIGNATURE

2.

3.

4.

5.

6.

7.

8.

9.

10.

EXPERIMENT-1

AIM: - Write a program to plot the following functions : a)impulse function b)unit step c)unit ramp d) exponential e) sinusoidal. REQUIREMENT: - Computer installed with MATLAB 7.1 PROGRAM CODE: t=(-1:.01:1);%range for time or division of x-axis %To plot unit step z=[zeros(100,1);ones(101,1)]; subplot(4,1,2); stem(t,z); xlabel('time'); ylabel('amp'); title('Fig-2 unit STEP Signal'); %To plot sin wave x1=sin(2*pi*10*t); subplot(4,1,4); plot(t,x1); xlabel('time'); ylabel('amp'); title('Fig-4 SIN Signal'); %To plot unit impulse signal y=[zeros(100,1); 1 ;zeros(100,1)]; subplot(4,1,1); stem(t,y); xlabel('time');

ylabel('amp'); title('Fig-1 unit IMPLUSE Signal'); %To plot Ramp signal subplot(4,1,3); plot(t,t); xlabel('time'); ylabel('amp'); title('Fig-3 RAMP Signal'); OUTPUT:

RESULT: - The Plot of various standard signals has been studied using MATLAB program.

EXPERIMENT-2

AIM: - To study the Modulation Process. REQUIREMENT: - Computer installed with MATLAB 6.1 PROGRAM CODE: n=-10:1:10; k=0:1:99; f=10/158; x=10-abs(n); X=x*(exp(-j*2*pi/100).^(n'*k)); c=cos(2*pi*f*n); z=x.*c; Z=z*(exp(-j*2*pi/100).^(n'*k)); y=1/2*((exp(-j*2*pi*f*n).*x)+(exp(j*2*pi*f*n).*x)); Y=y*(exp(-j*2*pi/100).^(n'*k)); Error=Y-Z; subplot(2,4,1); stem(n,x); title('Modulating Function'); xlabel('Time'); ylabel('Values'); subplot(2,4,2); stem(k,X); title('DFT of Modulating Function'); xlabel('Time'); ylabel('Values');

subplot(2,4,3); plot(n,c); title('CarrierFunction'); xlabel('Time'); ylabel('Values'); subplot(2,4,4); stem(n,z); title('Modulated Function'); xlabel('Time'); ylabel('Values'); subplot(2,4,5); stem(k,Z); title('DFT of Modulated Function'); xlabel('Time'); ylabel('Values'); subplot(2,4,6); stem(n,y); title('Modulated Function in exponential form'); xlabel('Time'); ylabel('Values'); subplot(2,4,7); stem(k,Y); title('DFT of Modulated Function in exponential form'); xlabel('Time'); ylabel('Values'); subplot(2,4,8);

stem(k,Error); title('Error Plot'); xlabel('Time'); ylabel('Values');

GRAPHS: -

Graphs for the Process of Modulation RESULT: - The Modulation Process has been studied using a MATLAB program. EXPERIMENT: 3

AIM: - To study the Aliasing Effect. REQUIREMENT: - Computer installed with MATLAB 6.1 PROGRAM CODE: n=0:1:99; f=5/158; f1=1/158; f2=10/158; f3=50/158; x=sin(2*pi*f*n); c1=cos(2*pi*f1*n); c2=cos(2*pi*f2*n); c3=cos(2*pi*f3*n); y1=x.*c1; y2=x.*c2; y3=x.*c3; subplot(4,2,1); plot(n,x); title('Modulating Function'); xlabel('Values'); ylabel('Amplitude'); subplot(4,2,2); plot(n,c1); title('Carrier Function 1'); xlabel('Values'); ylabel('Amplitude');

subplot(4,2,3); plot(n,c2); title('Carrier Function 2'); xlabel('Values'); ylabel('Amplitude'); subplot(4,2,4); plot(n,c3); title('Carrier Function 3'); xlabel('Values'); ylabel('Amplitude'); subplot(4,2,5); plot(n,y1); title('Frequency<Nyquest Rate (aliasing)'); xlabel('Values'); ylabel('Amplitude'); subplot(4,2,6); plot(n,y2); title('Frequency=Nyquest Rate'); xlabel('Values'); ylabel('Amplitude'); subplot(4,2,7); plot(n,y3); title('Frequency>Nyquest Rate( no aliasing)'); xlabel('Values'); ylabel('Amplitude');

GRAPHS: -

Graphs for the Aliasing Effect

RESULT: - The Aliasing Effect has been studied.

EXPERIMENT-4

AIM: - Write a program to find the DFT of the sequence REQUIREMENT: - Computer installed with MATLAB 7.1 PROGRAM CODE: clear all; x=[1 1 1 ]; %Given sequence N=50; L=length(x); if(N<L) error('N must be less than L'); end; x1=[x,zeros(1,N-L)]; %Appending of Zeros j = sqrt(-1); for k=0:N-1 %twiddle factor calculation for n=0:N-1 W=exp(-j*2*pi*n*k/N); x2(k+1 ,n+1)= W; end end X=x1*x2.'; %Computation of DFT by Dot product of Twiddle factor matrix & sequence magx=abs(X); anglex=angle(X); k=0:N-1; %To plot Mag. & Angle of output sequence subplot(2,1,1); stem(k,magx); xlabel('k'); ylabel('Mod of X'); title('Fig-1(a)Magnitude plot'); subplot(2,1,2); stem(k,anglex); xlabel('k'); ylabel('Angle of X'); title('Fig-1(b)Phase plot');

OUTPUT:

RESULT: - The DFT of the given discrete signal can be find out correctly with the help of this program code, it is checked with the help of above graphical results and manual calculations.

EXPERIMENT-5

AIM: - Write a program to plot the IDFT of a Sequence. REQUIREMENT: - Computer installed with MATLAB 7.1 PROGRAM CODE: %To compute clear all; xk=[6,2i-2,-2,-2i-2]; N=length(xk); for k=0:1:N-1 for n=0:1:N-1 x2(k+1,n+1)=p; end end xn=((xk*x2.')./N); magx=abs(xn); anglex=angle(xn); k=0:N-1; subplot(2,1,1); stem(k,magx); xlabel('k'); ylabel('Mod of X'); title('Fig-1(a)Magnitude plot'); subplot(2,1,2); %given Sequence %function to find length of sequence %loop from 0 to length(xk)-1 %loop from 0 to length(xk)-1 %twiddle factor matrix %end of loop 1 %end of loop 2 % Computation of IDFT %To compute Magnitude % To compute angle

p=exp(i*2*pi*n*k/N); %twiddle factor

%To plot the Magnitude and Angle of a sequence

stem(k,anglex); xlabel('k'); ylabel('Angle of X'); title('Fig-1(b)Phase plot'); OUTPUT:

Result: The IDFT of the given DFT signal can be find out correctly with the help of this program code, it is checked with the help of above graphical results and manual calculations.

EXPERIMENT-6

AIM: - Write a program to study of Windows. REQUIREMENT: - Computer installed with MATLAB 7.1 PROGRAM CODE: N=64; n=[0:1:N-1]; % Study of Rectangular Window Wr=rectwin(N); % Bartlett Window(Triangular Window Wb=triang(N); % Hamming Window Wh=hamming(N); % Blackman Window Wbl=Blackman(N); subplot(2,1,1),plot(n,Wr,n,Wb,n,Wh,n,Wbl);grid legend('Rectangular','Bartlett','Hamming','Blackman',4); xlabel('n'); ylabel('Amplitude'); title('Window Characteristics'); Wrdb=20*log(Wr); Wbdb=20*log(Wb); Whdb=20*log(Wh); Wbldb=20*log(Wbl); subplot(2,1,2),plot(n,Wrdb,n,Wbdb,n,Whdb,n,Wbldb);grid legend('Rectangular','Bartlett','Hamming','Blackman',4);

xlabel('n'); ylabel('Amplitude in db'); title('Window Characteristics in db'); OUTPUT:

Result: The various windows have been studied with the help of the above program code in this experiment.

Experiment: 7
AIM: To design Butterworth Band Pass Filter. clear all; alphap=2; alphas=20; wp=[.2*pi,.4*pi ws=[.1*pi,.5*pi [b,a]=butter(n,wn); w=0.1:.01:pi; [h,om]=freqz(b,a,w); vector h calculated %at the frequencies (in radians per sample) supplied by the vector w % To plot the Response w.r.t Normalized Freq. m=20*log(abs(h)); an=angle(h); subplot(2,1,1); plot(om/pi,m); grid; Ylabel('Gain in DBn'); Xlabel('Normalized Freq.'); subplot(2,1,2); plot(om/pi,an); grid; Ylabel('Phase in Radia'); Xlabel('Normalized Freq.'); %Returns the frequency response %Passband Attenuation in db %Passband Attenuation in db %Passband Frequency In Radian %Stopband Frequency In Radian %To design Butterworth filter

[n,wn]=buttord(wp/pi,ws/pi,alphap,alphas);

Output:

RESULT: - The Plot of Butterworth Band Pass Filter has been studied using MATLAB program.

Experiment: 8
AIM: To design Butterworth bandreject Filter

clear all; alphap=2; alphas=20; wp=[.2*pi,.4*pi]; ws=[.1*pi,.5*pi]; [b,a]=butter(n,wn,'stop'); w=0.1:.01:pi; [h,om]=freqz(b,a,w); vector h calculated %at the frequencies (in radians per sample) supplied by the vector w % To plot the Response w.r.t Normalized Freq m=20*log(abs(h)); an=angle(h); subplot(2,1,1); plot(om/pi,m); grid; Ylabel('Gain in DBn'); Xlabel('Normalized Freq.'); subplot(2,1,2); plot(om/pi,an); grid; Ylabel('Phase in Radia'); Xlabel('Normalized Freq.'); %Returns the frequency response %Passband Attenuation in db %Passband Attenuation in db %Passband Frequency In Radian %Stopband Frequency In Radian %To design Butterworth filter

[n,wn]=buttord(wp/pi,ws/pi,alphap,alphas);%Function for Filter for order and cutoff freq.

Output:-

RESULT: - The Plot of Butterworth Band Reject Filter has been studied using MATLAB program.

Experiment: 9
AIM: To design Butterworth High Pass Filter

clear all; alphap=.2;%Passband Attenuation in db alphas=30;%Passband Attenuation in db fp=400;%Passband Frequency In Hz fs=800;%Stopband Frequency In Hz F=2000;%Sampling Frequency In Hz omp=2*fp/F;% Frequency in Radians oms=2*fs/F;% Frequency in Radians [n,wn]=buttord(omp,oms,alphap,alphas);%Function for Filter [b,a]=butter(n,wn,'high'); w=0:.01:pi; [h,om]=freqz(b,a,w); %Returns the frequency response vector h calculated %at the frequencies (in radians per sample) supplied by the vector w % To plot the Response w.r.t Normalized Freq m=20*log(abs(h)); an=angle(h); subplot(2,1,1); plot(om/pi,m); grid; Ylabel('Gain in DB'); Xlabel('Normalized Freq.'); subplot(2,1,2); plot(om/pi,an); grid; Ylabel('Phase in Radian');

Xlabel('Normalized Freq.');

Output:-

RESULT: - The Plot of Butterworth High Pass Filter has been studied using MATLAB program.

Experiment: 10 AIM:To design Butterworth Low Pass Filter. clear all; alphap=2;%Passband Attenuation in db alphas=20;%Passband Attenuation in db fp=400;%Passband Frequency In Hz fs=800;%Stopband Frequency In Hz F=2000;%Sampling Frequency In Hz omp=2*fp/F;% Frequency in Radians oms=2*fs/F;% Frequency in Radians [n,wn]=buttord(omp,oms,alphap,alphas);%Function for Filter [b,a]=butter(n,wn); w=0:.01:pi; [h,om]=freqz(b,a,w,'whole'); %Returns the frequency response vector h calculated %at the frequencies (in radians per sample) supplied by the vector w % To plot the Response w.r.t Normalized Freq m=20*log(abs(h)); an=angle(h); subplot(2,1,1); plot(om/pi,m); grid; Ylabel('Gain in DB'); Xlabel('Normalized Freq.'); subplot(2,1,2); plot(om/pi,an); grid; Ylabel('Phase in Radian'); Xlabel('Normalized Freq.');

Output:

RESULT: - The Plot of Butterworth Low Pass Filter has been studied using MATLAB program.

Vous aimerez peut-être aussi