Name: Monika Sharma Class: M.E. (Communication Engg.) 1 Semester Subject:Mdct Lab College:Csit, Durg
Name: Monika Sharma Class: M.E. (Communication Engg.) 1 Semester Subject:Mdct Lab College:Csit, Durg
INDEX
S. NO. EXPERIMENTS 1. To generate sine & cosine signal. 2. To generate unit step &ramp signal. 3. To generate exponential signal. 4. To find correlation and autocorrelation between various signals. 5. To find convolution of signals and simulate response of LTI system. 6. To write different algorithms of FFT. 7. To design IIR and FIR digital filters. DATE 27-9-2012 1-10-2012 4-10-2012 9-10-2012 23-10-2012 30-10-2012 6-11-2012 SIGN
EXPERIMENT NO-1
AIM: To generate sine & cosine signals used in digital communication. APPARATUS REQUIRED: PC loaded with MATLAB Software. PROGRAM: (a) SINE SIGNAL
clc;
clear all; close all; pi=180; t=(0:10:4*pi); x=sin(2*t*pi); subplot(3,2,1);plot(t,x); xlabel('t'); ylabel('Magnitude'); title('Sinusoidal Signal') OUTPUT
clear all; close all; pi=180; t=(0:10:4*pi); x=cos(2*t*pi); subplot(3,2,2); plot(t,x); xlabel('t'); ylabel('Magnitude'); title('Cosine Signal'); OUTPUT:
RESULT:Sine & cosine signals used in digital communication are designed using Matlab and output is taken.
EXPERIMENT NO-2
AIM: To generate unit step & ramp signal used in digital communication. APPARATUS REQUIRED: PC loaded with MATLAB Software. PROGRAM: UNIT STEP SEQUENCE
clc;
clear all; close all; N=21; x=ones(1,N); n=0:1:N-1 subplot(3,2,4); stem(n,x); xlabel('t'); ylabel('Magnitude'); title('unit step sequence') OUTPUT:
clear all; close all; N=0:21; x=N; subplot(3,2,5); stem(N,x); xlabel('t'); ylabel('Magnitude'); title('unit ramp sequence') OUTPUT:
RESULT: Unit step & unit ramp signal used in digital communication are designed using Matlab and output is taken.
EXPERIMENT NO-3 AIM: To generate exponential signal used in digital communication. APPARATUS REQUIRED: PC loaded with MATLAB Software. PROGRAM: EXPONENTIAL SEQUENCE
clc;
clear all; close all; t=0:10 x=exp(t); subplot(3,2,6); stem(t,x); xlabel('t'); ylabel('Magnitude'); title('exponential sequence') OUTPUT:
RESULT: Exponential signals used in digital communication are designed using Matlab and output is taken.
EXPERIMENT NO-4 AIM: To find correlation and autocorrelation between various signals.. APPARATUS REQUIRED: PC loaded with MATLAB Software. THEORY: c = xcorr(x,y) returns the cross-correlation sequence in a length 2*N-1 vector, where x and y are length N vectors (N>1). If x and y are not the same length, the shorter vector is zero-padded to the length of the longer vector. PROGRAM: (a)AUTOCORRELATION
clc;
clear all; close all; x=input('enter the 1st sequence'); y=xcorr(x,x); figure; subplot(3,1,1); title('x sequence'); stem(x); xlabel('a(n)-->'); ylabel('input amplitude') subplot(3,1,2); stem(x); xlabel('b(n)-->'); ylabel('amplitude'); subplot(3,1,3); stem(fliplr(y)); xlabel('c(n)-->');
ylabel('output amplitude'); disp('output amplitude'); fliplr(y); title('auto corelation'); OUTPUT: >> autocorrelation enter the 1st sequence[1 2 3 4] output amplitude
x=input('enter first sequence'); h=input('enter second sequence'); y=xcorr(x,h); figure;subplot(3,1,1); stem(x);ylabel('amp--->'); xlabel('(a)n---->'); subplot(3,1,2); stem(h);ylabel('amp---->'); xlabel('(b)n------>'); subplot(3,1,3); stem(fliplr(y)); ylabel('amp--->'); xlabel('(c)n--->'); disp('the resultant signal is'); fliplr(y) OUTPUT: enter first sequence [1 2 3 4] enter second sequence[4 3 2 1] the resultant signal is
ans =
4.0000
1.0000
RESULT: Correlation and autocorrelation between various signals are designed using Matlab and output is taken
EXPERIMENT NO-5 AIM: To find convolution of signals and simulate response of LTI system APPARATUS REQUIRED: PC loaded with MATLAB Software. PROGRAM: LINEAR CONVOLUTION clc; clear all; close all; disp('linear convolution program'); x=input('enter i/p x(n):'); m=length(x); h=input('enter i/p h(n):'); n=length(h); x=[x,zeros(1,n)]; subplot(2,2,1), stem(x); title('i/p sequencce x(n)is:'); xlabel('---->n'); ylabel('---->x(n)');grid; h=[h,zeros(1,m)]; subplot(2,2,2), stem(h); title('i/p sequencce h(n)is:'); xlabel('---->n'); ylabel('---->h(n)');grid;
end subplot(2,2,[3,4]),stem(y); title('convolution of x(n) & h(n) is :'); xlabel('---->n'); ylabel('---->y(n)');grid; OUTPUT: linear convolution program enter i/p x(n):[1 2 3 4] enter i/p h(n):[1 2] convolution of x(n) & h(n) is y(n):
RESULT: Convolution of signals are designed and response of LTI system is simulated using Matlab and output is taken
EXPERIMENT NO-6
AIM: To write different algorithms of FFT APPARATUS REQUIRED: PC loaded with MATLAB Software. Y = fft(X) returns the discrete Fourier transform (DFT) of vector X, computed with a fast Fourier transform (FFT) algorithm. If X is a matrix, fft returns the Fourier transform of each column of the matrix. If X is a multidimensional array, fft operates on the first nonsingleton dimension.
PROGRAM:
RESULT: FFT algorithms are designed using Matlab and output is taken
EXPERIMENT NO-7 AIM: To design IIR and FIR digital filters APPARATUS REQUIRED: PC loaded with MATLAB Software. THEORY:Syntax [n,Wn] = buttord(Wp,Ws,Rp,Rs) [n,Wn] = buttord(Wp,Ws,Rp,Rs,'s') Description buttord calculates the minimum order of a digital or analog Butterworth filter required to meet a set of filter design specifications. Digital Domain [n,Wn] = buttord(Wp,Ws,Rp,Rs) returns the lowest order, n, of the digital Butterworth filter that loses no more than Rp dB in the passband and has at least Rs dB of attenuation in the stopband. The scalar (or vector) of corresponding cutoff frequencies, Wn, is also returned. Use the output arguments n and Wn in butter. Syntax hd = cheby1(d) hd = cheby1(d,'matchexactly',match) Description hd = cheby1(d) designs a Chebyshev I IIR digital filter using the specifications supplied in the object d. hd = cheby1(d,'matchexactly',match) returns a Chebyshev I IIR filter where the filter response matches the specified response exactly for one filter band. match, which specifies which filter band to match, is either passband--match the passband specification exactly in the final filter. stopband--match the specified stopband performance exactly in the final filter. Syantax:h = fir1(n,wn,kaiser(n+1,beta),'noscale'); The kaiserord function estimates the filter order, cutoff frequency, and Kaiser window beta parameter needed to meet a given set of frequency domain specifications. The ripple in the passband is roughly the same as the ripple in the stopband. As you can see from the frequency response, this filter nearly meets the specification.
PROGRAM: (a) FIR FILTER USING KAISER WINDOW clear all; wc=0.5*pi;%cutoff frequency N=25; b=fir1(N,wc/pi,kaiser (N+1,.5));%Beeta=.5 w=0:.01:pi; h=freqz(b,1,w); plot(w/pi,20*log10(abs(h))); hold on; b=fir1(N,wc/pi,kaiser(N+1,3.5));%Beeta=3.5 w=0:.01:pi; h=freqz(b,1,w); plot(w/pi,20*log10(abs(h)),'-.'); grid; hold on b=fir1(N,wc/pi,kaiser(N+1,8.5));%Beeta=8.5 w=0:.01:pi; h=freqz(b,1,w); plot(w/pi,20*log10(abs(h))); xlabel('Normalised frequency\omega/\pi') ylabel('Magnitude in dB');
OUTPUT
Fig: FIR lowpass filter using kaiser window (b)IIR FILTER (chebyshev type) clear all; alphap=2;% Passband attenuation in dB alphas=20;%Stopband attenuation in dB wp=[.2*pi,.4*pi];%Passband frequency in radians ws=[.1*pi,.5*pi];%Stopband frequency in radians % To find the cutoff frequency and the order of the filet [n,wn]=buttord(wp/pi,ws/pi,alphap,alphas) %system function of the filter [b,a]=cheby1(n,alphap,wn) w=0:.01:pi; [h,ph]=freqz(b,a,w); m=20*log(abs(h)); an=angle(h);
subplot(2,1,1); plot(ph/pi,m); ylabel('gain in dB'); xlabel('Normalized frequency') subplot(2,1,2); plot(ph/pi,an); ylabel('phase in radians'); xlabel('Normalised frequency');
OUTPUT
RESULT: IIR and FIR digital filters are designed using Matlab and output is taken