Full Transcript

EX. NO. : NAME : DATE: REG. NO. : DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING SECA2501 DIGITAL SIGNAL PROCESSING LAB 1 EX. NO. :...

EX. NO. : NAME : DATE: REG. NO. : DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING SECA2501 DIGITAL SIGNAL PROCESSING LAB 1 EX. NO. : NAME : DATE: REG. NO. : LIST OF EXPERIMENT Sl. No. DESCRIPTION MARKS(10) FACULTY SIGN 1. Generation of signals- Discrete form & Continuous form 2 Generation of Periodic and non-periodic signals. 3 a. Linear Convolution b. Auto Correlation c. Cross Correlation 4 Determination of Z Transform and Inverse Z Transform. 5 Impulse response of first order and second order systems. 6 Design and Implementation of IIR filter a.Butterworth Low Pass Filter b.Butterworth High Pass Filter c.Butterworth Band Pass Filter d. Butterworth Band stop Filter 6 a. Chebyshev Low Pass Filter b. Chebyshev High Pass Filter c. Chebyshev Band pass Filter d. Chebyshev Band stop Filter Design and Implementation of FIR filter by a. Rectangular & Hamming Window b. Kaiser Window 7 8. Determine the frequency contents of a continuous-time signal in the discrete-time domain (Spectral estimate) 9 Design and Implementation of Sampling & Reconstruction 10 Design and Implementation of Circular Convolution. 11. Design and simulation of Modulation & Demodulation. 12 a. Discrete Fourier Transform a. Inverse Discrete Fourier Transform 13. a. Frequency response of a system b. Step response of a system 14 a) Study Of TMS320C3X Processor b) Study Of ADSP21XX Processor c) Study Of ADSP21XX Processor 2 EX. NO. : NAME : DATE: REG. NO. : 1.GENERATION OF SIGNALS DISCRETE AND CONTINUOUS FORM AIM: To write a program in MATLAB to generate signals in discrete and continuous form. ALGORITHM: 1. Get the value of n for the sequences. 2. Use the desired formula for generating the signals. 3. Use the keyword stem for generating the discrete signal. 4. Use the keyword plot for generating the continuous signal. 5. Plot the graph. 6. Stop. FORMULA USED: Unit impulse: Unit step: Sine signal: x(n)= A sin (wn+θ) Cosine signal: x(n)= A cos (wn+θ) Exponential Signal: x(n)= exp (n) 3 EX. NO. : NAME : DATE: REG. NO. : PROGRAM : clc; N=21; x=ones(1,N); n=0:1:N-1; subplot(6,2,1); stem(n,x); xlabel('n'); ylabel('x(n)'); title('Discrete Unit Step Signal'); N=21; x=ones(1,N); n=0:1:N-1; subplot(6,2,2); plot(n,x); xlabel('n'); ylabel('y(n)'); title('Continuous Unit Step Signal'); N=21; x=sin(.2*pi*n); n=0:1:N-1; subplot(6,2,3); stem(n,x); xlabel('n'); ylabel('x(n)'); title('Discrete Sinusoidal Signal'); N=21; x=sin(.2*pi*n); n=0:1:N-1; subplot(6,2,4); plot(n,x); xlabel('n'); ylabel('y(n)'); title('continuous sinusoidal signal'); 4 EX. NO. : NAME : DATE: REG. NO. : N=21; x=cos(.2*pi*n); n=0:1:N-1; subplot(6,2,5); stem(n,x); xlabel('n'); ylabel('x(n)'); title('Discrete Cosine Signal'); N=21; x=cos(.2*pi*n); n=0:1:N-1; subplot(6,2,6); plot(n,x); xlabel('n'); ylabel('y(n)'); title('continuous cosine Signal'); N=21; x=n; n=0:1:N-1; subplot(6,2,7); stem(n,x); xlabel('n'); ylabel('x(n)'); title('Discrete Ramp Signal'); N=21; x=n; n=0:1:N-1; subplot(6,2,8); plot(n,x); xlabel('n'); ylabel('y(n)'); title('continuous ramp signal'); 5 EX. NO. : NAME : DATE: REG. NO. : N=21; x=exp(n); n=0:1:N-1; subplot(6,2,9); stem(n,x); xlabel('n'); ylabel('x(n)'); title('Discrete Exponential Signal'); N=21; x=exp(n); n=0:1:N-1; subplot(6,2,10); plot(n,x); xlabel('n'); ylabel('y(n)'); title('Continuous Exponential Signal'); N=21; x=[ones(1,1),zeros(1,N-1)]; n=0:1:N-1; subplot(6,2,11); stem(n,x); xlabel('n'); ylabel('x(n)'); title('Discrete Exponential Signal'); N=21; x=[ones(1,1),zeros(1,N-1)]; n=0:1:N-1; subplot(6,2,12); plot(n,x); xlabel('n'); ylabel('y(n)'); title('Continuous Impulse Signal'); 6 EX. NO. : NAME : DATE: REG. NO. : SIMULATED OUTPUT: RESULT: Thus the program was executed in MATLAB and the output was verified. 7 EX. NO. : NAME : DATE: REG. NO. : 2. PERIODIC & APERIODIC SEQUENCES AIM: To write program in MATLAB to generate periodic & aperiodic sequence. ALGORITHM: 1. Define the values of n,n1,etc. 2. Split the given function for step of 1 (or) 0.1,etc 3. Calculate a signal that is periodic with respect to the input signal. 4. Plot the graph of the given input signal and periodic signal. 5. Calculate a signal that is a periodic with r to the input signal. 6. Plot the graph of given input signal and aperiodic signal. 7. Stop PROGRAM: clear all; n=0:1:50; n1=0:1:50; x1=sin(.2*pi*n); x2=sin(.4*pi*n); x3=sin(.2*pi*n)+sin(.4*pi*n); x4=sin(.5*n1) subplot(2,2,1); stem(n,x1); xlabel('n'); ylabel('x1(n)'); axis([0 50 -1 1]); subplot(2,2,2); stem(n,x2); xlabel('n'); ylabel('x2(n)'); axis([0 50 -1 1]); subplot(2,2,3); stem(n,x3); xlabel('n'); ylabel('x3(n)'); axis([0 50 -2 2]); subplot(2,2,4); stem(n1,x4); 8 EX. NO. : NAME : DATE: REG. NO. : xlabel('n'); ylabel('x4(n)'); axis([0 50 -1 1]); SIMULATED OUTPUT: \ RESULT : Thus the program was executed in MATLAB & the output was verified. 9 EX. NO. : NAME : DATE: REG. NO. : 3.A LINEAR CONVOLUTION AIM: To write a program in MATLAB to perform linear convolution of two signals. ALGORITHM: 1. Get two signals g(m) and h(p) in matrix form. 2. The convoluted signal is denoted as y(n). 3. y(n) is given by the formula ∞ y(n) = Σ [ g(k) h (n-k) ] where n=0 to m+p-1 k=-∞ 4. Stop. FORMULA USED : The linear convolution is given by  g(n)   h(k) f (n  k) k    PROGRAM:- close all; clear all; clc; g=[1,-1,2,-2,3,-3,4,-4]; h=[-1,1]; n1=length(g); n2=length(h); m=0:1:n1-1; figure(); subplot(2,2,1); stem(m,g); xlabel('m'); ylabel('g(m)'); grid; title('Input Sequence-1'); n=0:1:n2-1; subplot(2,2,2); stem(n,h); xlabel('n'); ylabel('h(n)'); 10 EX. NO. : NAME : DATE: REG. NO. : grid; title('Input Sequence-2'); y=conv(g,h); n3=n1+n2-1; x=0:1:n3-1; subplot(2,2,3); stem(x,y); disp(y); xlabel('x'); ylabel('y(x)'); grid; title('Output Sequence'); SIMULATED OUTPUT: RESULT: Thus the program was executed in MATLAB and the output was verified. 11 EX. NO. : NAME : DATE: REG. NO. : 3.B AUTO – CORRELATION AIM : To write a program in MATLAB to perform auto correlation of an input sequence. ALGORITHM : 1. Get the signal x(n) of length n in matrix form. 2. The correlated signal is denoted as y(n). 3. y(n) is given by the formula ∞ y(n) = Σ x(k) x(k-n) k=-∞ where n= -(N-1) to (N-1). 4. Stop. FORMULA USED: PROGRAM: close all; clear all; clc; g=[1,2,3,4]; n1=length(g); m=0:1:n1-1; figure(); subplot(2,2,1); stem(m,g); xlabel('m'); ylabel('g(m)'); grid(); title('Input SEquence-1'); y=xcorr(g,g); n2=n1+n1-1; x=0:1:n2-1; subplot(2,2,2); 12 EX. NO. : NAME : DATE: REG. NO. : stem(x,y); disp(y); xlabel('x'); ylabel('y(x)'); grid; title('Output Sequence'); SIMULATED OUTPUT : RESULT : Thus the program was executed in MATLAB and the output was verified. 13 EX. NO. : NAME : DATE: REG. NO. : 3.C CROSS – CORRELATION AIM : To write a program in MATLAB to perform cross correlation of two sequences. ALGORITHM : 1. Get two signals x(m) & h(p) in the matrix form. 2. The correlated signal is denoted as y(n). 3. y(n) is given by the formula ∞ y(n)= Σ [ x(k) h(k-n)] k=-∞ where n=-[max(m,p)-1] to [max(m,p)-1] 4. Stop. PROGRAM : close all; clear all; clc; g=[1,2,3,4]; h=[4,3,2,1]; n1=length(g); n2=length(h); m=0:1:n1-1; figure(); subplot(2,2,1); stem(m,g); xlabel('m'); ylabel('g(m)'); grid; title('Input Sequence-1'); n=0:1:n2-1; subplot(2,2,2); stem(n,h); xlabel('n'); ylabel('h(n)'); grid; title('Input Sequence-2'); 14 EX. NO. : NAME : DATE: REG. NO. : y=xcorr(g,h); n3=n1+n2-1; x=0:1:n3-1; subplot(2,2,3); stem(x,y); disp(y); xlabel('x'); ylabel('y(x)'); grid; title('Output Sequence'); SIMULATED OUTPUT : RESULT : 15 EX. NO. : NAME : DATE: REG. NO. : 4. Z TRANSFORMS AND INVERSE Z TRANSFORMS A. Z TRANSFORM AIM: To write a program to illustrate the Z transforms process using MATLAB functions. ALGORITHM: 1. Mention Number of Frequency Points, Numerator Coefficients and Denominator Coefficients. 2. Compute the frequency response of Z transform of Unit circle 3. Plot the Frequency Response. 4. Plot the Z transform using freqz function in MATLAB. 5. Plot the Real, Imaginary and Magnitude plots, Formula: The z-transform is defined as The inverse Z transform is given by PROGRAM: close all; clear all; clc; k = input('Number of frequency points = '); % Read in the numerator and denominator coefficients num = input('Numerator coefficients = '); den = input('Denominator coefficients = '); % Compute the frequency response/Evaluate Z transform on unit circle w = 0:pi/(k-1):pi; h = freqz(num, den, w); % Plot the frequency response subplot(2,2,1) plot(w/pi,real(h));grid 16 EX. NO. : NAME : DATE: REG. NO. : title('Real part') xlabel('\omega/\pi'); ylabel('Amplitude') subplot(2,2,2) plot(w/pi,imag(h));grid title('Imaginary part') xlabel('\omega/\pi'); ylabel('Amplitude') subplot(2,2,3) plot(w/pi,abs(h));grid title('Magnitude Spectrum') xlabel('\omega/\pi'); ylabel('Magnitude') subplot(2,2,4) plot(w/pi,angle(h));grid title('Phase Spectrum') xlabel('\omega/\pi'); ylabel('Phase, radians') SIMULATED OUTPUT: RESULT: The program is executed successfully and plotted input and output waveforms. 17 EX. NO. : NAME : DATE: REG. NO. : 4.B. INVERSE Z TRANSFORMS AIM: To write a program to illustrate the Inverse Z transforms process using MATLAB functions. ALGORITHM: 1. The function impz provides the samples of the time domain sequence 2. where num and den are row vectors containing the coefficients of the numerator and denominator polynomials of G(z) in ascending powers of z−1, L is the desired number of the samples of the inverse transform, 3. g is the vector containing the samples of the inverse transform starting with the sample at n = 0, t is the length of g, and FT is the specified sampling frequency in Hz with default value of unity. 4. The function y=filter(num,den,x) can also be used to calculate the input response of a z- transform. Where num, den represent vectors containing numerator and denominator coefficients of z-transform. 5. While x represents input to the filter / z-transform.The length of output y is equal to input x. If an impulse input sequence is passed to the z-transform , the output will be the inverse z- transform 6. Plot the Frequency Response. 7. Plot the Z transform using freqz function in MATLAB. 8. Plot the Real, Imaginary , Magnitude and Phase plots. 18 EX. NO. : NAME : DATE: REG. NO. : PROGRAM: close all; clear all; clc; %definition of numerator and denominator coefficients num=[0.1+.4*i 5.05]; den=[1.9+0.3*i.12]; %Finding the inverse z transform of G(z) [a,b]=impz(num,den); %Evaluating on Unit Circle i.e. Fourier Transform [c,d]=freqz(num,den); % Plotting of x[n] and it's fourier transform subplot(2,2,1) stem(b,real(a)) title('Real Part of g[n]') xlabel('Samples'); ylabel('Magnitude') grid on subplot(2,2,2) stem(b,imag(a)) title('Imaginary Part of g[n]') xlabel('Samples'); ylabel('Magnitude') grid on subplot(2,2,3) plot(d/pi,abs(c)) title('Magnitude Spectrum of g[n]') xlabel('\omega/\pi'); ylabel('Magnitude') grid on subplot(2,2,4) plot(d/pi,angle(c)) title('Phase Spectrum of g[n]') xlabel('\omega/\pi'); ylabel('Phase, radians') grid on 19 EX. NO. : NAME : DATE: REG. NO. : SIMULATED OUTPUT: Z TRANSFORM OUTPUT: Number of frequency points = 3 Numerator coefficients = 3 Denominator coefficients = 3 RESULT: The program is executed successfully and plotted input and output waveforms. 20 EX. NO. : NAME : DATE: REG. NO. : 5. IMPULSE RESPONSE OF FIRST ORDER AND SECOND ORDER SYSTEMS. AIM: To write a program to illustrate the Z transforms process using MATLAB functions ALGORITHM 1. Specify the difference equation coefficients of the filter 2. Calculate Feedforward coefficients(ff) 3. Calculate Feedback coefficient i.e., no feedback(fb) 4. Create a sample vector, n = 0:5; Adjust as per need 5. Compute the impulse response of the system using function impz(ff, fb, n); 6. Plot the impulse response THEORY The response of a system when an impulse input signal is applied to it, is called the impulse response. It is denoted as h(t) for continuous time systems and h[n] for discrete time systems. Impulse response used to specify the response of a system to an impulse input signal in the time domain. Where, an impulse signal is a signal of infinite magnitude and infinitesimally small in time. Mathematically, the impulse signal is expressed as follows: Overall, the impulse response of a system allows us to analyze and study the system behavior for its stability, time domain properties, frequency response, etc. Impulse Response of a First−Order System The following MATLAB program demonstrates the calculation and visualization of the impulse response of a first order system. Let the following is the transfer function representing a first−order system: PROGRAM : % MATLAB code for computing the impulse Response of a First-order digital filter % Specify the difference equation coefficients of the filter ff = [0.7, 0.35]; % Feedforward coefficients fb = 1; % Feedback coefficient i.e., no feedback % Create a sample vector n = 0:5; % Adjust as per need % Compute the impulse response of the system h = impz(ff, fb, n); % Plot the impulse response plot(n, h); title('Impulse Response of First-Order Digital Filter'); xlabel('Sample Index (n)'); ylabel('Impulse Response'); grid on; 21 EX. NO. : NAME : DATE: REG. NO. : OUTPUT : Impulse Response of the Second−Order Recursive Digital Filter The following MATLAB program demonstrates the calculation of the impulse response of a second−order recursive digital filter with infinite impulse response. Let the following difference equation represents the digital filter: r[n] = 0.7c[n]+0.35c[n−1]+0.55c[n−2] % MATLAB code for computing the impulse Response of a second-order digital filter % Specify the difference equation coefficients of the filter ff = [0.7, 0.35, 0.55]; % Feedforward coefficients fb = 1; % Feedback coefficient i.e., no feedback % Create a sample vector n = 0:5; % Adjust as per need % Compute the impulse response of the system h = impz(ff, fb, n); % Plot the impulse response stem(n, h); title('Impulse Response of Second-Order Digital Filter'); xlabel('Sample Index (n)'); ylabel('Impulse Response'); grid on; 22 EX. NO. : NAME : DATE: REG. NO. : OUTPUT : RESULT: Thus the program was executed in MATLAB and the output was verified. 23 EX. NO. : NAME : DATE: REG. NO. : 6.A BUTTERWORTH LOW PASS FILTER AIM : To write a program in MATLAB to perform Butterworth LPF Operation. ALGORITHM : 1. Get the pass band and stop band ripples. 2. Get the pass band and stop band edge frequencies. 3. Get the sampling frequency. 4. Calculate the order of the filter using the formula, N =(log√(10^0.1αs-1)(10^0.1αp-1))/(log(Ωs/Ωp)). 5. Find the filter coefficients. 6. Draw the magnitude and phase responses. 7. Stop. FORMULA: The transfer function of the Butterworth reference analog prototype filter is expressed as follows: Where, Sk is the k-th pole of the Butterworth filter transfer function, N is the filter order. For N=5, the transfer function is: The transformation to a high-pass analog filter: 24 EX. NO. : NAME : DATE: REG. NO. : PROGRAM : clc; clear all; close all; alphap=input('Enter The Pass Band Ripple'); alphas=input('Enter The Stop Band Ripple'); fp=input('Enter The Pass Band Frequency'); fs=input('Enter The Stop Band Frequency'); f=input('Enter The Sampling Frequency'); omp=2*(fp/f); oms=2*(fs/f); [h,wn]=buttord(omp,oms,alphap,alphas) [b,a]=butter(h,wn,'low') 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); grid; ylabel('Gain in db'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase In Radians'); xlabel('Normalized Frequency'); 25 EX. NO. : NAME : DATE: REG. NO. : SIMULATED OUTPUT (LPF): INPUT : Enter the pass band ripple: 0.4 Enter the stop band ripple: 30 Enter the pass band frequency: 400 Enter the stop band frequency: 800 Enter the sampling frequency: 2000 COMMAND WINDOW: h =4 wn =0.5821 b =0.1518 0.6073 0.9109 0.6073 0.1518 a =1.0000 0.6418 0.6165 0.1449 0.0259 RESULT : Thus the program was executed in MATLAB and the output was verified. 26 EX. NO. : NAME : DATE: REG. NO. : 6.B BUTTERWORTH HIGH PASS FILTER AIM: To write a program in MATLAB to perform Butterworth HPF operation. ALGORITHM: 1. Get the pass band and stop band ripples. 2. Get the pass band and stop band edge frequencies. 3. Get the sampling frequency. 4. Calculate the order of the filter using the formula, N =(log√(10^0.1αs-1)(10^0.1αp-1))/(log(Ωs/Ωp)). 5. Find the filter coefficients. 6. Draw the magnitude and phase responses. 7. Stop. PROGRAM : clc; clear all; close all; alphap=input('Enter The Pass Band Ripple'); alphas=input('Enter The Stop Band Ripple'); fp=input('Enter The Pass Band Frequency'); fs=input('Enter The Stop Band Frequency'); f=input('Enter The Sampling Frequency'); omp=2*pi*(fp/f); oms=2*pi*(fs/f); [h,wn]=buttord(omp,oms,alphap,alphas) [b,a]=butter(h,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); grid; ylabel('Gain in db'); xlabel('Normalised Frequency'); 27 EX. NO. : NAME : DATE: REG. NO. : subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase In Radians'); xlabel('Normalized Frequency'); SIMULATED OUTPUT (HPF): INPUT: Enter the pass band ripple :0.4 Enter the stop band ripple :30 Enter the pass band frequency : 400 Enter the stop band frequency : 800 Enter the sampling frequency : 2000 COMMAND WINDOW : h =4 wn =0.5821 b =0.0535 -0.2139 0.3209 -0.2139 0.0535 a =1.0000 0.6418 0.6165 0.1449 0.0259 RESULT : Thus the program was executed in MATLAB and the output was verified. 28 EX. NO. : NAME : DATE: REG. NO. : 6.C BUTTERWORTH BAND PASS FILTER AIM : To write a program in MATLAB to perform Butterworth BPF operation. ALGORITHM : 1. Get the pass band and stop band ripples. 2. Calculate the order of the filter using the formula, N =(log√(10^0.1αs-1)(10^0.1αp-1))/(log(Ωs/Ωp)). 3. Find the filter coefficients. 4. Draw the magnitude and phase responses. 5. Stop. PROGRAM : close all; clear all; clc; alphap=input('Enter The Pass Band Ripple'); alphas=input('Enter The Stop Band Ripple'); wp=[0.2, 0.4]; ws=[0.1, 0.5]; [h,wn]=buttord(wp,ws,alphap,alphas) [b,a]=butter(h,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); grid; ylabel('Gain in db'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase In Radians'); xlabel('Normalized Frequency'); 29 EX. NO. : NAME : DATE: REG. NO. : INPUT : Enter the pass band ripple : 0.4 Enter the stop band ripple : 30 SIMULATED OUTPUT: RESULT : Thus the program was executed in MATLAB and the output was verified. 30 EX. NO. : NAME : DATE: REG. NO. : 6.D BUTTERWORTH BAND STOP FILTER AIM: To write a program in MATLAB to perform Butterworth BSF operation. ALGORITHM: 1. Get the pass band and stop band ripple. 2. Calculate the order of the filter using the formula, N =(log√(10^0.1αs-1)/(10^0.1αp-1))/(log(Ωs/Ωp)). 3. Find the filter coefficients. 4. Draw the magnitude and phase responses. 5. Stop. PROGRAM : close all; clear all; clc; alphap=input('Enter the pass band ripple'); alphas=input('Enter the stop band ripple'); wp=[0.2, 0.4]; ws=[0.1, 0.5]; [h,wn]=buttord(wp,ws,alphap,alphas) [b,a]=butter(h,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); grid; ylabel('Gain in db'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase in Radians'); xlabel('Normalized Frequency'); 31 EX. NO. : NAME : DATE: REG. NO. : INPUT : Enter the pass band ripple:0.4 Enter the stop band ripple:30 SIMULATED OUTPUT: RESULT : Thus the program was executed in MATLAB and the output was verified. 32 EX. NO. : NAME : DATE: REG. NO. : 6.A CHEBYSHEV LOW PASS FILTER AIM : To write a program in MATLAB to perform the chebyshev LPF operation. ALGORITHM : 1. Get the pass band and stop band ripples. 2. Calculate the order of the filter using the formula, N = (cosh^-1(√((10^0.1αs-1)/(10^0.1αp-1))))/(cosh^-1(Ωs/Ωp)). 3. Find the filter coefficients. 4. Draw the magnitude and phase responses. 5. Stop. FORMULA: Chebyshev analog filter is defined via expression: Ω is the frequency; N is the filter order; ε is a parameter used to define maximum oscillations in the passband frequency response; and TN is the Chebyshev polynomial. The Chebyshev polynomial TN(Ω) can be obtained via recursive relations: The values of poles are expressed as: Where, si is the i-th transfer function pole of analog prototype filter (complex value); σi is the pole; and Ωi is the imaginary pole. 33 EX. NO. : NAME : DATE: REG. NO. : Where, N is the filter order; and i=1, 2,..., N. The value of parameter ε is obtained via expression: Transfer function is expressed as: The value of A0 is found via expression: For N=5, the transfer function is: Low-pass filter: In the transform function, s\\Ωc is used instead of s, where Ωc is a desirable cut-off frequency in the passband. For high pass filter The transformation in a band-stop analog filter: The value of the constant Ω0 can be found via expression: s1 is a lower cut-off frequency in the stopband and Ωs2 is a higher cut-off frequency in the stopband.The transformation into a band-pass analog filter is expressed as: 34 EX. NO. : NAME : DATE: REG. NO. : The value of the constant Ω0 can be found via expression: Where,Ωp1 is a lower cut-off frequency in the passband and Ωp2 is a higher cut-off frequency in the passband. PROGRAM : clc; close all; clear all; ap=input('Enter the pass band attenuation in db'); as=input('Enter the Stop Band in db'); wp=.2*pi; ws=.3*pi; [n,wn]=cheb1ord(wp/pi,ws/pi,ap,as); [b,a]=cheby1(n,ap,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); grid; ylabel('Gain in db'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase in Radians'); xlabel('Normalised Frequency'); title('Cheby Low Pass Filter'); 35 EX. NO. : NAME : DATE: REG. NO. : SIMULATED OUTPUT: INPUT : Give the pass band attenuation in db : 0.4 Give the stop band in db : 30 RESULT : Thus the program was executed in MATLAB and the output was verified. 36 EX. NO. : NAME : DATE: REG. NO. : 6.B CHEBYSHEV HIGH PASS FILTER AIM : To write a program in MATLAB to perform chebyshev HPF operation. ALGORITHM : 1. Get the pass band and stop band ripples. 2. Calculate the order of the filter using the formula, N = (cosh^-1(√((10^0.1αs-1)/(10^0.1αp-1))))/(cosh^-1(Ωs/Ωp)). 3. Find the filter coefficients. 4. Draw the magnitude and phase responses. 5. Stop. PROGRAM : close all; clear all; clc; ap=input('Enter The Pass Band Attenuation In Db'); as=input('Give The Stop Band In Db'); wp=.2*pi; ws=.3*pi; [n,wn]=cheb1ord(wp/pi,ws/pi,ap,as);cv [b,a]=cheby1(n,ap,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); grid; ylabel('Gain In Db'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase In Radians'); xlabel('Normalised Frequency'); 37 EX. NO. : NAME : DATE: REG. NO. : title('Cheby High Pass Filter'); SIMULATED OUTPUT: INPUT : Give the pass band attenuation in db:0.4 Give the stop band attenuation in db:30 RESULT : Thus the program was executed in MATLAB & the output was verified. 38 EX. NO. : NAME : DATE: REG. NO. : 6.C.CHEBYSHEV BAND PASS FILTER AIM : To write a program in MATLAB to perform chebyshev BPF operation. ALGORITHM : 1. Get the pass band and stop band ripples. 2. Calculate the order of the filter using the formula, N = (cosh^-1(√((10^0.1αs-1)/(10^0.1αp-1))))/(cosh^-1(Ωs/Ωp)). 3. Find the filter coefficients. 4. Draw the magnitude and phase responses. 5. Stop. PROGRAM : clc; close all; clear all; ap=input('Give The Pass Band Attenuation In Db'); as=input('Give The Stop Band In Db'); wp=[.2*pi,.4*pi]; ws=[.1*pi,.5*pi]; [n,wn]=cheb1ord(wp/pi,ws/pi,ap,as); [b,a]=cheby1(n,ap,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); grid; ylabel('Gain In Db'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase In Radians'); xlabel('Normalised Frequency'); title('Cheby Band Pass Filter'); 39 EX. NO. : NAME : DATE: REG. NO. : SIMULATED OUTPUT: INPUT : Give the pass band attenuation in db:0.4 Give the stop band in db :30 RESULT : Thus the program was executed in MATLAB & the output was verified. 40 EX. NO. : NAME : DATE: REG. NO. : 6.D. CHEBYSHEV BAND STOP FILTER AIM : To write a program in MATLAB to perform chebyshev BSF operation. ALGORITHM : 1. Get the pass band and stop band ripples. 2. Calculate the order of the filter using the formula, N = (cosh^-1(√((10^0.1αs-1)/(10^0.1αp-1))))/(cosh^-1(Ωs/Ωp)). 3. Find the filter coefficients. 4. Draw the magnitude and phase responses. 5. Stop. PROGRAM : clc; close all; clear all; ap=input('Give The Pass Band Attenuation In Db'); as=input('Give The Stop Band In Db'); wp=[.2*pi,.4*pi]; ws=[.1*pi,.5*pi]; [n,wn]=cheb1ord(wp/pi,ws/pi,ap,as); [b,a]=cheby1(n,ap,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); grid; ylabel('Gain In Db'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(om/pi,an); grid; ylabel('Phase In Radians'); 41 EX. NO. : NAME : DATE: REG. NO. : xlabel('Normalised Frequency'); title('Cheby Band Stop Filter'); SIMULATED OUTPUT: \ INPUT : Give the pass band attenuation in db:0.4 Give the stop band in db:30 RESULT : Thus the program was executed in MATLAB & the output was verified. 42 EX. NO. : NAME : DATE: REG. NO. : 7.A RECTANGULAR AND HAMMING WINDOW AIM : To write a program in MATLAB to perform rectangular & hamming window operation. ALGORITHM : 1. Clear all the m-files &close them. 2. Get wc1 & wc2 values. 3. Calculate hd(n), hw(n), h(n) for various values for rectangular window. ∞ hd(n)=1/2π∫H(e^jω).e^jω hω(n)=1. -∞ 4. Calculate hd(n), w(n), h(n) for various values for hamming window. hd(n)=1/πn sin(πn/2). hω(n) = {0.54+0.46 cos(2πn/N-1) ; -(N+1/2)≤n≤(N-1/2) {0 ; otherwise. {I○(β)/I○(α) ; -(N+1/2)≤n≤(N-1/2) {0 ;else. β =α (1-(2n/N-1)^2)^1/2. 5. Plot the graph. 6. Stop. 43 EX. NO. : NAME : DATE: REG. NO. : PROGRAM : clc; clear all; close all; wc1=.25*pi; wc2=.75*pi; N=25; a=(N-1)/2; eps=0.001; n=0:1:N-1; hd=(sin(wc2*(n-a+eps))-sin(wc1*(n-a+eps)))./(pi*(n-a+eps)); wr=boxcar(N); hn=hd.*wr'; w=0:0.01:pi; h=freqz(hn,1,w); plot(w/pi,abs(h));hold on wh=hamming(N); hn=hd.*wh'; w=0:0.01:pi; h=freqz(hn,1,w); plot(w/pi,abs(h),'--'); xlabel('Normalised Frequency/omega/pi'); ylabel('Magnitude'); hold off; 44 EX. NO. : NAME : DATE: REG. NO. : SIMULATED OUTPUT: \ RESULT : Thus the program was executed in MATLAB & the output was verified. 45 EX. NO. : NAME : DATE: REG. NO. : 7.B KAISER WINDOW AIM : To write a program in MATLAB to perform kaiser window operation. ALGORITHM : 1. Clear all the m-files & close them. 2. Calculate β and w(n) 3. Find Wc = 0.5 * Pi 4. Calculate hd(n), hw(n), h(n) for various values of Kaiser window. 5. Plot the graph n Hint: To create the Kaiser windows, use the Matlab command kaiser(N,beta) command where N is the length of the filter and beta is the shape parameter β. PROGRAM : clc; close all; clear all; wc=0.5*pi; N=25; b=fir1(N,wc/pi,kaiser(N+1,8.5)); w=0: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,8.5)); w=0:0.01:pi; h=freqz(b,1,w); 46 EX. NO. : NAME : DATE: REG. NO. : plot(w/pi,20*log10(abs(h)),'-'); grid; hold on; xlabel('Normalised Frequency/omega/pi'); ylabel('Magnitude In Db'); hold off; SIMULATED OUTPUT: RESULT : Thus the program was executed in MATLAB & the output was verified. 47 EX. NO. : NAME : DATE: REG. NO. : 8 SPECTRAL ESTIMATATION AIM: To write a program in MATLAB to find spectral estimate. ALGORITHM: 1. Define the value of n. 2. Calculate x=cos(2*pi*8500xn/100). 3. Find the fast fourier transform. 4. Find the complex conjugate of fft. 5. Calculate E=(xk.conj)/length h(n). 6. Plot the graph. Theory: The spectrum of a signal is fundamentally a description of the energy of a signal as a function of frequency. It may also be a function of time and frequency which leads to the time-varying or the so-called time-frequency spectrum description. Spectra are represented by their amplitude and phase or more meaningfully, by the squared magnitude, which is referred to as the Power Spectrum. Spectrum of a signal is computed by FFT which is given by equation PROGRAM: clear all; clc; n=0:50; x=cos(2*pi*500*n/1000); xk=fft(x); xk_conj=conj(xk); k=0:50; esdk=(xk.*xk_conj)/length(n); stem(k,esdk); xlabel('k'); ylabel('Magnitude'); 48 EX. NO. : NAME : DATE: REG. NO. : SIMULATED OUTPUT: RESULT: Thus the program was executed in MATLAB & the output was verified. 49 EX. NO. : NAME : DATE: REG. NO. : 9 Design and Implementation of Sampling & Reconstruction AIM: To write a program in MATLAB to illustrate concept of Sampling & Reconstruction. ALGORITHM: 1. Get the values of t. 2. Calculate the required parameters T,fm,x,fs1,fs2,fs3. 3. Plot the continious and discrete signal. 4.Calcualte x(n) that shows sampling effect. 5.Stop PROGRAM: clear all; t=-10:0.01:10; T=4;fm=1/T; x=cos(2*pi*fm*t); fs1=1.6*fm; fs2=2*fm; fs3=8*fm; n1=-4:1:4; xn1=cos(2*pi*n1*fm/fs1); subplot(2,2,1);plot(t,x); xlabel('time in sec');ylabel('x(t)'); title('continuous time signal'); subplot(2,2,2);stem(n1,xn1); hold on; subplot(2,2,2);plot(n1,xn1); xlabel('n');ylabel('x(n)'); title('discrete time signal with fsfm'); SIMULATED OUTPUT: RESULT: Thus the program was executed in MATLAB & the output was verified 51 EX. NO. : NAME : DATE: REG. NO. : 10 CIRCULAR CONVOLUTION AIM : To write a program in MATLAB to perform circular convolution of two signals. ALGORITHM : 1. Get the two input sequences g(m) and h(p). 2. Get the length of the sequences. 3. check whether the lengths are equal using the loop 4. if(N3=0) h=[h,zeros (1,N3)]; else g=[g,zeros (1,-N3)]; end 5. Compute the circular convolution of the sequence. 6. y(n) = y(n)+g(i)*h(j); 7. stop. FORMULA USED: PROGRAM : close all; clear all; clc; g=[1,3,5,6,2]; h=[1,2,3]; n1=length(g); n2=length(h); m=0:1:n1-1; subplot(2,2,1); stem(m,g); xlabel('m'); ylabel('g(m)'); 52 EX. NO. : NAME : DATE: REG. NO. : grid; title('Input Sequence-1'); n=0:1:n2-1; subplot(2,2,2); stem(n,h); xlabel('n'); ylabel('h(n)'); grid; title('Input Sequence-2'); N=max(n1,n2); n3=n1-n2; if(n3>0) h=[h,zeros(1,n3)]; else g=[g,zeros(1,-n3)]; end for x=1:N y(x)=0; for i=1:N j=x-i+1; if(j

Use Quizgecko on...
Browser
Browser