AIM: To sample a continuous time signal and perform reconstruction. SOFTWARE USED: MATLAB software THEORY : In the field of signal processing, the sampling theorem is a fundamental between continuous time signals (often called analog signals) and discrete time signal. It establishes a sufficient condition referred as Nyquist criterion, that permits a discrete sequence of samples to capture all the information from the continuous time signal of finite bandwidth. Sampling Theorem: A bandlimited signal can be reconstructed exactly if it is sampled at a rate at least twice the maximum frequency component in it. ALGORITHM: Enter the time period and amplitude Calculate Fm=1/T Generate continuous time signal X=A*cos*2*pi(Fm*t) Select three sampling frequencies Fs1=Fm Fs2=2*Fm Fs3=8*Fm Generate discrete time signal xn1 for Fs1=Fm Generate discrete time signal xn2 for Fs2=2*Fm Generate discrete time signal xn3 for Fs3=8*Fm Plot the continuous time signal and discrete time signal in the same figure using subplot function Use hold on function used to superimpose continuous and discrete signals Label x and y axis Give a title for each plot PROGRAM: OUTPUT: FIGURE: RESULT: Thus the continuous time signal is sampled and reconstructed. EXPT.NO. 4 COMPUTATION OF DFT AND IDFT USING FUNCTIONS DATE : AIM: To compute DFT and IDFT using MATLAB SOFTWARE USED: MATLAB software THEORY : The discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency. The discrete Fourier transform converts a sequence of N complex numbers into another sequence of complex numbers, which is defined by ALGORITHM: Enter the input sequence Enter the length of DFT If length of DFT is greater than input sequence then pad the input sequence with zeros equal to the difference between the two. Call the DFT function In the function For n=0 to N-1, k=0 to N-1 Compute nk=n’*k wN=exp((-j*2*pi)/N) wNnk=wN.^nk xk=xn*wNnk Find the magnitude and phase angle and plot the graph. Call the IDFT function In the function For n=0 to N-1, k=0 to N-1 Compute IDFT nk=n’*k wN=exp((j*2*pi)/N) wNnk=wN.^nk xn=(xk*wNnk)/N Plot the graph for IDFT PROGRAM : OUTPUT: COMMAND WINDOW: FIGURES: RESULT: Thus the DFT and IDFT of a sequence is computed using MATLAB. EXPT.NO.4 b) COMPUTATION OF FFT DATE : AIM: To compute Fast Fourier Transform using MATLAB SOFTWARE USED: MATLAB software THEORY : Fast Fourier Transform Computes the Discrete Fourier Transform of X using Fast Fourier Transform Algorithm. Fourier analysis converts a signal from its original domain (often time or space) to a representation in the frequency domain. The DFT is obtained by decomposing a sequence of values into components of different frequencies. . ALGORITHM: Enter the input sequence x(n) Enter the length of DFT N Call the FFT function Display the values of FFT PROGRAM : OUTPUT: COMMAND WINDOW: RESULT: Thus the FFT of a sequence is computed using MATLAB. EXPT.NO.6 DESIGN OF FIR FILTER DATE : AIM: To write a MATLAB Script to design a low pass FIR filter for noise cancellation. APPARATUS REQUIRED: MATLAB. THEORY: A digital filter is a discrete time LTI system. It is classified based on the length of the impulse response as IIR filters: Where h [n] has infinite number of samples and is recursive type. FIR filters: They are non-recursive type and h [n] has finite number of samples. The transfer function is of the form: N 1 H (z) hn z n n0 This implies that it has (N-1) zeros located anywhere in the z-plane and (N-1) poles at Z = h. THE FIR FILTER CAN BE DESIGNED BY: Fourier series method Frequency sampling method Window method TYPES OF WINDOWS: 1. Rectangular 2. Triangular 3. Hamming 4. Hanning 5. Blackman 6. Kaiser Library Functions: fir1 FIR filter design using the Window method. B = fir1(N,Wn) designs an Nth order low pass FIR digital filter and returns the filter coefficients of vector B of length (N+1). The cut-off frequency Wn must be between 0 < Wn < 1.0, with 1.0 corresponding to half the sample rate. The filter B is real and has linear phase. The normalized gain of the filter at Wn is -6 dB. B = fir1(N,Wn,'high') designs an Nth order high pass filter. You can also use B = fir1(N,Wn,'low') to design a low pass filter. If Wn is a two-element vector, Wn = [W1 W2], fir1 returns an order N band pass filter with pass band W1 < W < W2.You can also specify B = fir1(N,Wn,'bandpass'). If Wn = [W1 W2], B = fir1(N,Wn,'stop') will design a band-stop filter. If Wn is a multi-element vector, Wn = [W1 W2 W3 W4 W5 ... WN], fir1 returns a N-order multi-band filter with bands 0 < W < W1, W1 < W < W2, ..., WN < W < 1. B = fir1(N,Wn,'DC-1') makes the first band a pass band. B = fir1(N,Wn,'DC-0') makes the first band a stop band. B = fir1(N,Wn,WIN) designs an N-th order FIR filter using the vector WIN of (N+1) length to window the impulse response. If empty or omitted, fir1 uses a Hamming window of length N+1. For a complete list of available windows, see the Help for the WINDOW function. KAISER and CHEBWIN can be specified with an optional trailing argument. For example, B = fir1(N,Wn,kaiser(N+1,4)) uses a Kaiser window with beta=4. B = fir1(N,Wn,'high',chebwin(N+1,R)) uses a Chebyshev window with R decibels of relative sidelobe attenuation.For filters with a gain other than zero at Fs/2, e.g., high pass and band stop filters, N must be even. Otherwise, N will be incremented by one. In this case, the window length should be specified as N+2. By default, the filter is scaled so the center of the first pass band has magnitude exactly one after windowing. Use a trailing 'noscale' argument to prevent this scaling, B = fir1(N,Wn,'noscale'), B = fir1(N,Wn,'high','noscale'), B = fir1(N,Wn,wind,'noscale'). You can also specify the scaling explicitly, e.g. fir1(N,Wn,'scale'), etc. Window Functions: w = hamming(n) returns an n-point symmetric Hamming window in the column vector w. n should be a positive integer. w = hanning(n) returns an n-point symmetric Hann window in the column vector w. n must be a positive integer. w=triang(n) returns an n-point triangular window in the column vector w. The triangular window is very similar to a Bartlett window. The Bartlett window always ends with zeros at samples 1 and n, while the triangular window is nonzero at those points. For n odd, the center (n-2) points of triang(n-2) are equivalent to bartlett(n). w = rectwin(n) returns a rectangular window of length n in the column vector w. This function is provided for completeness. A rectangular window is equivalent to no window at all. ALGORITHM: Simulate a noisy signal by adding a cosine signal with random noise signal. Specify the cut-off frequency and normalize it. Use fir1 function to design the filter and obtain the filter co-efficients. Specify the order of the filter and the type of window in the function. View the filter’s frequency response using the fvtool. Implement the filtering operation using the filter function. Plot the noisy signal and the filtered signal. Analyse the filter operation by changing the type of window, the order of the window and so on. PROGRAM OUTPUT: COMMAND WINDOW: Output RESULT: Thus the noisy signal is filtered by using FIR filter. EXPT.NO. Design of Digital Butterworth IIR FILTER DATE : AIM: To write a MATLAB Script to design a digital Butterworth low pass filter. SOFTWARE USED: MATLAB. THEORY: A digital filter is a linear time invariant discrete time system. The digital filters are classified into two, based on their lengths of impulse response 1. Finite Impulse response (FIR).They are of non-recursive type and h [n] has finite number of samples 2. Infinite Impulse response (IIR). h[n] has infinite number of samples. They are of recursive type. Hence, their transfer function is of the form ALGORITHM: Enter the stop band and pass band ripples Enter the stop band and pass band edge frequencies Enter the Sampling Frequency Calculate the order of the filter Find the filter coefficients Draw the Magnitude and phase responses PROGRAM : OUTPUT: COMMAND WINDOW: FIGURES: RESULT: Thus the digital low pass Butterworth filter was designed the frequency response has been plotted. EXPT.NO. Design of Digital Chebyshev IIR FILTER DATE : AIM: To write a MATLAB Script to design of Digital Chebyshev IIR low pass filter. SOFTWARE USED: MATLAB. THEORY: A digital filter is a linear time invariant discrete time system. The digital filters are classified into two, based on their lengths of impulse response 1. Finite Impulse response (FIR).They are of non-recursive type and h [n] has finite number of samples 2. Infinite Impulse response (IIR). h[n] has infinite number of samples. They are of recursive type. Hence, their transfer function is of the form ALGORITHM: Enter the stop band and pass band ripples Enter the stop band and pass band edge frequencies Enter the Sampling Frequency Calculate the order of the filter Find the filter coefficients Draw the Magnitude and phase responses PROGRAM : OUTPUT: COMMAND WINDOW: FIGURES: RESULT: Thus the digital low pass Butterworth filter was designed the frequency response has been plotted.