manual 19032012

Upload: hirankur-khillare

Post on 14-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 MANUAL 19032012

    1/33

    Experiment 1

    AIM OF EXPT:

    To generate and study Discrete Time Signals for ex. unit step, ramp, impulse using MATLAB.

    LIST OF EQIPMENTS/ APPARATUS :1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):Common Sequences:

    Unit Impulse, Unit Step, and Unit RampSince MATLAB is a programming language, an endlessvariety of

    different signals is possible. Here are some statements that generate several commonly usedsequences, including

    the unit impulse, unit step, and unit ramp functions.Signal Processing Toolbox Waveform Generation: Time Vectors and SinusoidsA variety of toolboxfunctions generate waveforms. Most require you to begin with a vector representing a time base.Consider generating data with a 1000 Hz sample frequency, for example. An appropriate time vectoris t = (0:0.001:1)';where the MATLAB colon operator creates a 1001-element row vector that represents time runningfrom zero to one second in steps of one millisecond. The transpose operator (') changes the rowvector into a column; the semicolon (;) tells MATLAB to compute but not display the result. Given tyou can create a sample signal y consisting of two sinusoids, one at 50 Hz and one at 120 Hz withtwice the amplitude. y = sin(2*pi*50*t) + 2*sin(2*pi*120*t);The new variable y, formed from vector t, is also 1001 elements long. You can add normallydistributed white noise to the signal and graph the first fifty points using randn('state',0);yn = y + 0.5*randn(size(t));

    plot(t(1:50),yn(1:50))

    Common Sequences: Unit Impulse, Unit Step, and Unit RampSince MATLAB is a programminglanguage, an endless variety of different signals is possible. Here are some statements that

  • 7/27/2019 MANUAL 19032012

    2/33

    generate several commonly used sequences, including the unit impulse, unit step, and unit rampfunctions: t = (0:0.001:1)';y = [1; zeros(99,1)]; % impulsey = ones(100,1); % step (filter assumes 0 initial cond.)y = t; % rampy = t.^2;y = square(4*t);All of these sequences are column vectors. The last three inherit their shapes from t.

    Representing Signals Common Sequences: Unit Impulse, Unit Step, and Unit

    Procedure:

    1. Double click on MATLAB icon on the desktop.2. Click on File > New > M-File.3. Type the program in the M-File Editor.4. Save the file with a relavant name.5. Run the program by clicking on the Run Icon in the toolbar and observe the output.

    Program :[ It should be computer print ]1)% generation of d iscrete time signalsh = [1; zeros(99,1)];xlabel('n');ylabel('h(n)');title('generation of impu lse discrete time signals');stem(h)2)% generation of d iscrete time signalst = (0:0.001:1);r = t;xlabel('n');ylabel('r(n)');title('generation of ramp discrete time signals');stem(r)3)% generation of d iscrete time signalsu = ones(100,1);xlabel('n');ylabel('u(n)');title('generation of unit step discrete time signals');stem(u)

    Conclusion:By using MATLAB DTS are generated and studied.

  • 7/27/2019 MANUAL 19032012

    3/33

    EXPT NO.2

    AIM OF EXPT: - To Study the Sampling Theorem using MATLAB.

    LIST OF EQIPMENTS/ APPARATUS :1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):Sampling theorem

    According to sampling theorem, an analog signal can be exactly reconstructed from its samples if thesampling rate is at least twice the highest frequency component present in the signal. This means, if thesignal contains the highest frequency component of 1 KHz, the sampling rate must be at least 2 KiloSamples/ Second. This sampling rate is also known as Nyquist rate. What if sampling theorem is notsatisfied..? violation of sampling theorem means, sampling the signal at a sample rate less than Nyquist

    rate. This leads to unacceptable distortion in the signal. this distortion is known as aliasing. Due to aliasing,the components present in the input signal whose frequency is higher Nyquist frequency will be sampled asa signal of lower frequency. And this aliased samples in turn corrupts the original signal which is lower thanNyquist frequency. Due to the presence of aliasing, a signal that contains frequency components higherthan Nyquist frequency can not be reconstructed from it's samples. The effect of aliasing is shown in thefigure below. The signal shown in black color is the original signal. While the signal shown in violate color isthe aliased signal because of improper sampling. From the figure it is obvious that the aliased signal will bepresent in the sampled data as a lower frequency signal. And this will affect the original content at thatfrequency.

    It should be noted that the information in between two consecutive samples is lost forever. But stillthe entire signal can be reconstructed from the samples as long as Sampling theorem is satisfied.

    Sampling and quantization

    Sampling can be viewed theoretically as multiplying the original signal with a train of pulses with unitamplitude. This leaves the original signal with information at descrete points with magnitude of signalpresent in the original signal at that position. This is illustrated in the figure below.

  • 7/27/2019 MANUAL 19032012

    4/33

    After processing the samples has to be converted back to analog voltage. This is done by using a deviceknown as DAC (Digital to Analog Converter). DAC does exactly opposite to what ADC has done. The DACtakes digital data as input and produces corresponding analog voltage. DACs are less expensive comparedto ADCs.

    Taking all these in account, we can now come to the idea of physical realization of a Digital SignalProcessing system. As we know, in a DSP system, the signal has to be first converted in to digital format,process it and then convert back to analog format. All theses things can be achieved by using a systemshown below.

    Digital Signal Processor

    Since the DSP system represents the signal as numbers, the digital signal processor must be capableof manipulating numbers. As we know, it is nothing but a computer. A general purpose computer or adedicated digital signal processor can be used for signal processing. The dedicated signal processors arespecially designed for DSP applications, and which outperforms the general purpose computers inprocessing efficiency. this is because the instructions, memory and other features of a dedicated DigitalSignal Processor is optimized for DSP applications. Many companies like Texas Instruments, Analog Devices,and Motorola etc... has dedicated Signal Processors optimized for different applications.

    Digital Signal Processing techniques

    The applications of DSP are numerous, simple toys to satellites... DSP is well suited for any applicationsince it can do almost all processing that can be done using analog circuitry. The major drawbacks of DSPare comparatively high cost and distortion because of finite word length used in signal processors. Since in

    DSP applications, most of the hardware can be replaced with software, eventually DSP will become costeffective in most of the applications. The Digital Signal Processor mimics the behavior of analog circuitryusing some DSP techniques and algorithms. The techniques that are commonly used in DSP are convolution,spectral analysis and manipulation, filtering etc.....

    CONCLUSION: From above discussion and analysis using MATLAB the Sampling

    Theorem is studied.

  • 7/27/2019 MANUAL 19032012

    5/33

    EXPT NO.3

    AIM OF EXPT: - To Study the Decimation of Signal using MATLAB.

    LIST OF EQIPMENTS/ APPARATUS :1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):

    Decimation reduces the original sampling rate for a sequence to a lower rate, the opposite

    of interpolation. The decimation process filters the input data with a low pass filter and

    then resamples the resulting smoothed signal at a lower rate. y = decimate(x,r) reduces

    the sample rate of x by a factor r. The decimated vector y is r times shorter in length thanthe input vector x. By default, decimate employs an eighth-order low passes Chebyshev

    Type I filter. It filters the input sequence in both the forward and reverse directions toremove all phase distortion, effectively doubling the filter order. y = decimate(x,r,n) usesan order n Chebyshev filter. Orders above 13 are not recommended because of numerical

    instability. MATLAB displays a warning in this case. y = decimate(x,r,'fir') uses a 30-

    point FIR filter, instead of the Chebyshev IIR filter. Here decimate filters the inputsequence in only one direction. This technique conserves memory and is useful for

    working with long sequences. y = decimate(x,r,n,'fir') uses a length n FIR filter.

    decimate

    Decimation decrease sampling rate

    Syntax

    y = deci mate(x, r )y = deci mate(x, r , n)y = deci mat e( x, r , ' f i r ' )y = deci mat e( x, r , n, ' f i r ' )

    Description

    Decimation reduces the original sampling rate for a sequence to a lower rate, the opposite

    of interpolation. The decimation process filters the input data with a lowpass filter and

    then resamples the resulting smoothed signal at a lower rate.

    y = deci mate(x, r ) reduces the sample rate ofx by a factorr . The decimated vectory

    is r times shorter in length than the input vectorx. By default, deci mat e employs an

    eighth-order lowpass Chebyshev Type I filter with a cutoff frequency of 0.8*(Fs/2)/r . It

  • 7/27/2019 MANUAL 19032012

    6/33

    filters the input sequence in both the forward and reverse directions to remove all phase

    distortion, effectively doubling the filter order.

    y = deci mate(x, r , n) uses an ordern Chebyshev filter. Orders above 13 are notrecommended because of numerical instability. In this case, a warning is displayed.

    Note For better results when r is greater than 13, you should breakr into its

    factors and call deci mat e several times.

    y = deci mat e( x, r , ' f i r ' ) uses an order 30 FIR filter, instead of the Chebyshev IIR

    filter. Here deci mat e filters the input sequence in only one direction. This techniqueconserves memory and is useful for working with long sequences.

    y = deci mat e( x, r , n, ' f i r ' ) uses an ordern FIR filter.

    Examples

    Decimate a signal by a factor of four:

    t = 0: . 00025: 1; % Ti me vect orx = si n( 2*pi *30*t ) + si n( 2*pi *60*t ) ;y = deci mat e(x, 4) ;

    View the original and decimated signals:

    st em( x( 1: 120) ) , axi s( [ 0 120 - 2 2] ) % Or i gi nal si gnalt i t l e( ' Or i gi nal Si gnal ' )

    f i gurest em( y( 1: 30) ) % Deci mated si gnalt i t l e( ' Deci mat ed Si gnal ' )

    Algorithm

    deci mat e uses decimation algorithms 8.2 and 8.3 from[1]:

  • 7/27/2019 MANUAL 19032012

    7/33

    1. It designs a lowpass filter. By default, deci mat e uses a Chebyshev Type I filter

    with normalized cutoff frequency 0. 8/ r and 0.05 dB of passband ripple. For the

    f i r option, deci mat e designs a lowpass FIR filter with cutoff frequency 1/ r

    usingf i r 1.

    2. For the FIR filter, deci mat e applies the filter to the input vector in one direction.

    In the IIR case, deci mat e applies the filter in forward and reverse directions withf i l t f i l t .

    3. deci mat e resamples the filtered data by selecting every r th point.

    Note Depending on the CPU and operating system of your computer, the

    decimate function may use a lower filter order. If the specified filter order will

    produce passband distortion, caused by roundoff errors accumulated from theconvolutions needed to create the transfer function, the filter order is

    automatically reduced.

    Diagnostics

    Ifr is not an integer, deci mat e gives the following error message:

    Resampl i ng r at e R must be an i nt eger .

    Ifn specifies an IIR filter with order greater than 13, deci mat e gives the followingwarning:

    War ni ng: I I R f i l t er s above order 13 may be unr el i abl e.

    References

    [1]IEEE Programs for Digital Signal Processing, IEEE Press. New York: John Wiley &Sons, 1979. Chapter 8.

    See Also

    cheby1,downsampl e,f i l t f i l t ,f i r 1,mf i l t ,i nt erp,r esampl e

    Conclusion: - As per above study and MATLAB analysis the Decimation of Signal is

    studied

  • 7/27/2019 MANUAL 19032012

    8/33

    EXPT NO.4

    AIM OF EXPT: - To Study the Interpolation of Signal using MATLAB.LIST OF EQIPMENTS/ APPARATUS :

    1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):

    Interpolation increases the original sampling rate for a sequence to a higher rate. interp

    performs low pass interpolation by inserting zeros into the original sequence and then

    applying a special low pass filter. y = interp(x,r) increases the sampling rate of x by afactor of r. The interpolated vector y is r times longer than the original input x. y =

    interp(x,r,l,alpha) specifies l (filter length) and alpha (cut-off frequency). The defaultvalue for l is 4 and the default value for alpha is 0.5. [y,b] = interp(x,r,l,alpha) returnsvector b containing the filter coefficients used for the interpolation.

    interp

    Interpolation increase sampling rate by integer factor

    Syntax

    y = i nt er p( x, r )y = i nt erp( x, r , l , al pha)[ y, b] = i nt erp( x, r , l , al pha)

    Description

    Interpolation increases the original sampling rate for a sequence to a higher rate. i nt erpperforms lowpass interpolation by inserting zeros into the original sequence and then

    applying a special lowpass filter. The filter returned byi nt f i l t is identical to the filter

    used by i nt erp.

    y = i nt er p( x, r ) increases the sampling rate ofx by a factor ofr . The interpolated

    vectory is r times longer than the original input x.

    y = i nt erp(x, r , l , al pha) specifies l (filter length) andal pha (cut-off frequency). The

    default value forl is 4 and the default value foral pha is 0.5.

  • 7/27/2019 MANUAL 19032012

    9/33

  • 7/27/2019 MANUAL 19032012

    10/33

    Ifr is not an integer, i nt erp gives the following error message:

    Resampl i ng r at e R must be an i nt eger .

    References

    [1] Programs for Digital Signal Processing, IEEE Press, New York, 1979, Algorithm

    8.1.

    See Also

    deci mat e,downsampl e,i nt er p1,i nt f i l t resampl e,spl i ne,upf i r dn,upsampl e

    Conclusion: - As per above study and MATLAB analysis the Interpolation of Signal isstudied

  • 7/27/2019 MANUAL 19032012

    11/33

    EXPT NO.5

    AIM OF EXPT: - To Study the Speech processing: Dynamic range compression usingMATLAB.LIST OF EQIPMENTS/ APPARATUS :

    1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):

    Dynamic range compression

    Compresses the dynamic range of a signal by modifying the range of the magnitude ateach frequency bin. This nonlinear spectral modification is followed by an overlap-addFFT algorithm for reconstruction. Compression maps the dynamic range of the

    magnitude at each frequency bin from the range 0 to 100 dB to the range ymin to ymax

    dB. ymin and ymax are vectors in the MATLAB workspace with one element for eachfrequency bin (256 long in this case). The phase is not altered. This is a non-linear

    spectral modification This system might be used as a speech enhancement system for the

    hearing impaired. By compressing the dynamic range at certain frequencies, the listener

    should be able to perceive quieter sounds without being blasted out when they get loud,as in linear equalization. After repositioning the input and output figures so you can see

    them at the same time, change the Slider Gain from 1 to 1000 to 10000.Notice the

    relative heights of the output peaks change as you increase the magnitude. The algorithmin this simulation is derived from a patented system for adaptive processing of telephone

    voice signals for the hearing impaired. The system was developed by Alvin M. Terry and

    Thomas P. Krauss at US West Advanced Technologies Inc., US patent number5,388,185. A reference for the OLA method is: Rabiner, L. R. and R. W. Schafer.Digital

    Processing of Speech Signals. Englewood Cliffs, NJ: Prentice Hall, 1978, pgs. 274-277.

    This system decomposes the input signal into overlapping sections of length 256.The overlap is 192, so that every 64 samples, a new section is defined and a new FFT is

    computed. After the spectrum is modified and the inverse FFT is computed, the

    overlapping parts of the sections are added together. If no spectral modification is

    performed, the output is a scaled replica of the input. To use this system to demonstrate

    frequency dependent dynamic range compression, start the simulation. Afterrepositioning the input and output figures so you can see them at the same time, change

    the Slider Gain from 1 to 1000 to 10000.Notice the relative heights of the output peakschange as you increase the magnitude.

  • 7/27/2019 MANUAL 19032012

    12/33

    Dynamic Range Compression Using

    Overlap-Add Reconstruction

    This demo illustrates a method of compressing the dynamic range of a signal bymodifying the range of the magnitude at each frequency bin. This nonlinear spectral

    modification is followed by an overlap-add FFT algorithm for reconstruction. This

    system might be used as a speech enhancement system for the hearing impaired. Thealgorithm in this simulation is derived from a patented system for adaptive processing of

    telephone voice signals for the hearing impaired originally developed by Alvin M. Terry

    and Thomas P. Krauss at US West Advanced Technologies Inc., US patent number5,388,185.

  • 7/27/2019 MANUAL 19032012

    13/33

  • 7/27/2019 MANUAL 19032012

    14/33

    This system decomposes the input signal into overlapping sections of length 256. The

    overlap is 192 so that every 64 samples, a new section is defined and a new FFT is

    computed. After the spectrum is modified and the inverse FFT is computed, theoverlapping parts of the sections are added together. If no spectral modification is

    performed, the output is a scaled replica of the input. A reference for the overlap-add

    method used for the audio signal reconstruction is Rabiner, L. R. and R. W. Schafer.Digital Processing of Speech Signals. Englewood Cliffs, NJ: Prentice Hall, 1978, pgs.

    274-277.

    Compression maps the dynamic range of the magnitude at each frequency bin from the

    range 0 to 100 dB to the range ymi n to ymax dB. ymi n andymax are vectors in theMATLAB workspace with one element for each frequency bin; in this case 256. The

    phase is not altered. This is a non-linear spectral modification. By compressing the

    dynamic range at certain frequencies, the listener should be able to perceive quietersounds without being blasted out when they get loud, as in linear equalization.

    To use this system to demonstrate frequency-dependent dynamic range compression, startthe simulation. After repositioning the input and output figures so you can see them at the

    same time, change the Slider Gain from 1 to 1000 to 10000. Notice the relative heights

    of the output peaks change as you increase the magnitude.

    Conclusion: - As per above study and MATLAB analysis the Speech processing:

    Dynamic range compression is studied

  • 7/27/2019 MANUAL 19032012

    15/33

    Experiment 6

    AIM OF EXPT:To studyconvolution using MATLAB.

    LIST OF EQIPMENTS/ APPARATUS :1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):

    conv

    Convolution and polynomial multiplication

    Syntax

    w = conv( u, v)

    Description

    w = conv( u, v) convolves vectors u andv. Algebraically, convolution is the same operation as

    multiplying the polynomials whose coefficients are the elements ofu andv.

    Definition

    Let m = l engt h( u) andn = l ength(v) . Then wis the vector of length m+n- 1 whose kthelement is

    The sum is over all the values ofj which lead to legal subscripts foru( j ) andv(k+1- j ) ,

    specificallyj =max( 1, k+1- n) : mi n( k, m) . When m=n, this gives

    w( 1) = u(1) *v( 1)w( 2) = u(1) *v( 2) +u( 2) *v( 1)

    w( 3) = u( 1) *v( 3) +u( 2) *v( 2) +u( 3) *v( 1). . .w( n) = u( 1) *v( n) +u( 2) *v( n- 1) + . . . +u( n) *v( 1). . .w( 2*n- 1) = u( n) *v( n)

    Algorithm

  • 7/27/2019 MANUAL 19032012

    16/33

    The convolution theorem says, roughly, that convolving two sequences is the same as

    multiplying their Fourier transforms. In order to make this precise, it is necessary to pad the two

    vectors with zeros and ignore roundoff error. Thus, if

    X = f f t ( [ x zer os( 1, l engt h( y) - 1) ] )

    and

    Y = f f t ( [ y zer os( 1, l engt h( x) - 1) ] )

    then conv( x, y) = i f f t ( X. *Y)

    See Also

    conv2,convn,deconv,f i l t er

    convmt xandxcor r in the Signal Processing Toolbox

    Procedure:

    1. Double click on MATLAB icon on the desktop.2. Click on File > New > M-File.3. Type the program in the M-File Editor.4. Save the file with a relavant name.5. Run the program by clicking on the Run Icon in the toolbar and observe the output.

    Program :[ It should be computer print ]%convolution of two sequences

    x=[1 1 1 ];h=[1 1 1 ];y=conv(x,h);

    xlabel('n');ylabel('y(n)');title('convolution of two sequences x(n) and y(n)');stem(y);

    Conclusion:By using MATLAB CONVOLUTION of two sequence is studied.

  • 7/27/2019 MANUAL 19032012

    17/33

    Experiment 7

    AIM OF EXPT:To study fast fouriertransform using MATLAB.

    LIST OF EQIPMENTS/ APPARATUS :1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):

    fftDiscrete Fourier transform

    SyntaxY = f f t ( X)Y = f f t ( X, n)Y = f f t ( X, [ ] , di m)Y = f f t ( X, n, di m)

    Definition

    The functionsY=f f t ( x) andy=i f f t ( X) implement the transform and inverse transform pairgiven for vectors of length by:

    where

    is an th root of unity.

    Description

    Y = f f t ( X) returns the discrete Fourier transform (DFT) of vectorX, computed with a fastFourier transform (FFT) algorithm.

    IfX is a matrix, f f t returns the Fourier transform of each column of the matrix.

  • 7/27/2019 MANUAL 19032012

    18/33

    IfX is a multidimensional array, f f t operates on the first nonsingleton dimension.

    Y = f f t ( X, n) returns the n-point DFT. If the length ofX is less than n, X is padded with trailing

    zeros to length n. If the length ofX is greater than n, the sequence X is truncated. When X is amatrix, the length of the columns are adjusted in the same manner.

    Y = f f t ( X, [ ] , di m) andY = f f t ( X, n, di m) applies the FFT operation across the dimensiondi m.

    Examples

    A common use of Fourier transforms is to find the frequency components of a signal buried in a

    noisy time domain signal. Consider data sampled at 1000 Hz. Form a signal containing a 50 Hzsinusoid of amplitude 0.7 and 120 Hz sinusoid of amplitude 1 and corrupt it with some zero-

    mean random noise:

    Fs = 1000; % Sampl i ng f r equencyT = 1/ Fs; % Sampl e t i me

    L = 1000; % Lengt h of si gnalt = ( 0: L- 1) *T; % Ti me vect or% Sum of a 50 Hz si nusoi d and a 120 Hz si nusoi dx = 0. 7*si n( 2*pi *50*t ) + si n( 2*pi *120*t ) ;y = x + 2*r andn( si ze( t ) ) ; % Si nusoi ds pl us noi sepl ot ( Fs*t( 1: 50) , y( 1: 50) )t i t l e( ' Si gnal Cor r upt ed wi t h Zer o- Mean Random Noi se' )xl abel ( ' t i me ( mi l l i seconds)' )

  • 7/27/2019 MANUAL 19032012

    19/33

    It is difficult to identify the frequency components by looking at the original signal. Converting

    to the frequency domain, the discrete Fourier transform of the noisy signal y is found by takingthe fast Fourier transform (FFT):

    NFFT = 2 next pow2( L) ; % Next power of 2 f r om l engt h of yY = f f t ( y, NFFT) / L;f = Fs/ 2*l i nspace( 0, 1, NFFT/ 2+1) ;

    % Pl ot si ngl e- si ded ampl i t ude spect r um.pl ot ( f , 2*abs( Y( 1: NFFT/ 2+1) ) )t i t l e( ' Si ngl e- Si ded Ampl i t ude Spectr um of y( t ) ' )xl abel ( ' Frequency ( Hz) ' )yl abel ( ' | Y( f ) | ' )

    The main reason the amplitudes are not exactly at 0.7 and 1 is because of the noise. Several

    executions of this code (including recomputation ofy) will produce different approximations to

    0.7 and 1. The other reason is that you have a finite length signal. Increasing L from 1000 to10000 in the example above will produce much better approximations on average.

    Algorithm

    The FFT functions (f f t , f f t 2, f f t n, i f f t , i f f t 2, i f f t n) are based on a library called FFTW

    [3],[4]. To compute an -point DFT when is composite (that is, when ), the

    FFTW library decomposes the problem using the Cooley-Tukey algorithm[1], which first

    computes transforms of size , and then computes transforms of size . The

  • 7/27/2019 MANUAL 19032012

    20/33

    decomposition is applied recursively to both the - and -point DFTs until the problem canbe solved using one of several machine-generated fixed-size "codelets." The codelets in turn use

    several algorithms in combination, including a variation of Cooley-Tukey[5], a prime factor

    algorithm[6], and a split-radix algorithm[2]. The particular factorization of is chosen

    heuristically.

    When is a prime number, the FFTW library first decomposes an -point problem into three ()-point problems using Rader's algorithm[7]. It then uses the Cooley-Tukey

    decomposition described above to compute the ( )-point DFTs.

    For most , real-input DFTs require roughly half the computation time of complex-input DFTs.However, when has large prime factors, there is little or no speed difference.

    The execution time forf f t depends on the length of the transform. It is fastest for powers oftwo. It is almost as fast for lengths that have only small prime factors. It is typically several times

    slower for lengths that are prime or which have large prime factors.

    Note You might be able to increase the speed off f t using the utility functionf f t w,which controls the optimization of the algorithm used to compute an FFT of a particular

    size and dimension.

    Data Type Support

    f f t supports inputs of data types doubl e ands i ngl e. If you call f f t with the syntax y =

    f f t ( X, . . . ) , the output y has the same data type as the input X.

    See Also

    f f t 2,f f t n,f f t w,f f t shi f t ,i f f t

    df t mt x,f i l t er , andf r eqzin the Signal Processing Toolbox

    References

    [1] Cooley, J. W. and J. W. Tukey, "An Algorithm for the Machine Computation of the Complex

    Fourier Series,"Mathematics of Computation, Vol. 19, April 1965, pp. 297-301.

    [2] Duhamel, P. and M. Vetterli, "Fast Fourier Transforms: A Tutorial Review and a State of the

    Art," Signal Processing, Vol. 19, April 1990, pp. 259-299.

    [3] FFTW (ht t p: / / www. f f t w. or g)

    [4] Frigo, M. and S. G. Johnson, "FFTW: An Adaptive Software Architecture for theFFT,"Proceedings of the International Conference on Acoustics, Speech, and Signal Processing,

    Vol. 3, 1998, pp. 1381-1384.

    [5] Oppenheim, A. V. and R. W. Schafer,Discrete-Time Signal Processing, Prentice-Hall, 1989,p. 611.

    http://www.fftw.org/http://www.fftw.org/http://www.fftw.org/http://www.fftw.org/
  • 7/27/2019 MANUAL 19032012

    21/33

    [6] Oppenheim, A. V. and R. W. Schafer,Discrete-Time Signal Processing, Prentice-Hall, 1989,

    p. 619.

    [7] Rader, C. M., "Discrete Fourier Transforms when the Number of Data Samples Is Prime,"Proceedings of the IEEE, Vol. 56, June 1968, pp. 1107-1108.

    Procedure:

    1. Double click on MATLAB icon on the desktop.2. Click on File > New > M-File.3. Type the program in the M-File Editor.4. Save the file with a relavant name.5. Run the program by clicking on the Run Icon in the toolbar and observe the output.

    Program :[ It should be computer print ]Fs = 1000; % Sampl i ng f r equency

    T = 1/ Fs; % Sampl e t i meL = 1000; % Lengt h of si gnal

    t = ( 0: L- 1) *T; % Ti me vect or% Sum of a 50 Hz si nusoi d and a 120 Hz si nusoi dx = 0. 7*si n( 2*pi *50*t ) + si n( 2*pi *120*t ) ;y = x + 2*r andn( si ze( t ) ) ; % Si nusoi ds pl us noi sepl ot ( Fs*t( 1: 50) , y( 1: 50) )t i t l e( ' Si gnal Cor r upt ed wi t h Zer o- Mean Random Noi se' )xl abel ( ' t i me ( mi l l i seconds)' )

    NFFT = 2 next pow2( L) ; % Next power of 2 f r om l engt h of yY = f f t ( y, NFFT) / L;f = Fs/ 2*l i nspace( 0, 1, NFFT/ 2+1) ;

    % Pl ot si ngl e- si ded ampl i t ude spect r um.pl ot ( f , 2*abs( Y( 1: NFFT/ 2+1) ) )t i t l e( ' Si ngl e- Si ded Ampl i t ude Spectr um of y( t ) ' )xl abel ( ' Frequency ( Hz) ' )yl abel ( ' | Y( f ) | ' )

    Conclusion:By using MATLAB FAST FOURIER TRANSFORM is studied.

  • 7/27/2019 MANUAL 19032012

    22/33

  • 7/27/2019 MANUAL 19032012

    23/33

    By default, the filter is scaled so that the center of the first passband has a magnitude of exactly 1

    after windowing.

    b = f i r 1(n, Wn, 'ftype') specifies a filter type, where 'ftype' is:

    ' hi gh' for a highpass filter with cutoff frequency Wn.

    ' stop' for a bandstop filter, ifWn = [ w1 w2] . The stopband frequency range is specifiedby this interval.

    ' DC- 1' to make the first band of a multiband filter a passband.

    ' DC- 0' to make the first band of a multiband filter a stopband.

    f i r 1 always uses an even filter order for the highpass and bandstop configurations. This isbecause for odd orders, the frequency response at the Nyquist frequency is 0, which is

    inappropriate for highpass and bandstop filters. If you specify an odd-valuedn, f i r 1 incrementsit by 1.

    b = f i r 1(n, Wn, wi ndow) uses the window specified in column vectorwi ndowfor the design.

    The vectorwi ndowmust be n+1 elements long. If no window is specified, f i r 1 uses a Hamming

    window (seehammi ng) of length n+1.

    b = f i r 1(n, Wn, 'ftype', wi ndow) accepts both 'ftype' andwi ndowparameters.

    b = f i r 1( . . . , 'normalization') specifies whether or not the filter magnitude is normalized.

    The string 'normalization' can be the following:

    ' scal e' (default): Normalize the filter so that the magnitude response of the filter at thecenter frequency of the passband is 0 dB.

    ' noscal e' : Do not normalize the filter.

    The group delay of the FIR filter designed by f i r 1 is n/ 2.

    Algorithm

    f i r 1 uses the window method of FIR filter design[1]. Ifw(n) denotes a window, where 1 nN, and the impulse response of the ideal filter is h(n), where h(n) is the inverse Fourier transformof the ideal frequency response, then the windowed digital filter coefficients are given by

    Examples

    Example 1

    Design a 48th-order FIR bandpass filter with passband 0.35 0.65:

    b = f i r 1( 48, [ 0. 35 0. 65] ) ;f r eqz( b, 1, 512)

  • 7/27/2019 MANUAL 19032012

    24/33

    Example 2

    The chi r p. mat file contains a signal, y, that has most of its power above f s / 4, or half theNyquist frequency. Design a 34th-order FIR highpass filter to attenuate the components of the

    signal below f s / 4. Use a cutoff frequency of 0.48 and a Chebyshev window with 30 dB of

    ripple:

    l oad chi r p % Load y and f s.b = f i r 1( 34, 0. 48, ' hi gh' , chebwi n( 35, 30) ) ;f r eqz( b, 1, 512)

    References

    [1] Programs for Digital Signal Processing, IEEE Press, New York, 1979. Algorithm 5.2.

    See Also

    cf i r pm,f i l t er ,f i r 2,f i r c l s,f i r cl s1,f i r l s,f r eqz,kai ser or d,f i r pm,wi ndow

    Procedure:

    1. Double click on MATLAB icon on the desktop.2. Click on File > New > M-File.3. Type the program in the M-File Editor.4. Save the file with a relavant name.

  • 7/27/2019 MANUAL 19032012

    25/33

    5. Run the program by clicking on the Run Icon in the toolbar and observe the output.

    Program :[ It should be computer print ]

    As above.

    Conclusion:By using MATLAB fir filter window based desgin is studied.

  • 7/27/2019 MANUAL 19032012

    26/33

    Experiment 9

    AIM OF EXPT:To study IIR Filter design using MATLAB.

    LIST OF EQIPMENTS/ APPARATUS :1) MATLAB2) signal processing toolbox3) System with P4 and 1GB RAM etc.

    DISCRIPTION,CIRCUIT DIA, PROCEDURE ( ONLY GUIDELINES, IN BRIEF):

    butterButterworth analog and digital filter design

    Syntax[ z, p, k] = but t er ( n, Wn)[ z, p, k] = but t er ( n, Wn, 'ftype')[ b, a] = but t er( n, Wn)[ b, a] = but t er ( n, Wn, 'ftype')[ A, B, C, D] = but t er ( n, Wn)[ A, B, C, D] = but t er ( n, Wn, ' ftype' )[ z, p, k] = but t er ( n, Wn, ' s' )[ z, p, k] = but t er ( n, Wn, ' ftype' , ' s ' )[ b, a] = but t er ( n, Wn, ' s' )[ b, a] = but t er ( n, Wn, 'ftype', ' s ' )[ A, B, C, D] = but t er ( n, Wn, ' s' )

    [ A, B, C, D] = but t er ( n, Wn, ' ftype' , ' s ' )

    Description

    but t er designs lowpass, bandpass, highpass, and bandstop digital and analog Butterworthfilters. Butterworth filters are characterized by a magnitude response that is maximally flat in the

    passband and monotonic overall.

    Butterworth filters sacrifice rolloff steepness for monotonicity in the pass- and stopbands. Unless

    the smoothness of the Butterworth filter is needed, an elliptic or Chebyshev filter can generally

    provide steeper rolloff characteristics with a lower filter order.

    Digital Domain

    [ z, p, k] = but t er ( n, Wn) designs an ordern lowpass digital Butterworth filter with

    normalized cutoff frequency Wn. It returns the zeros and poles in length n column vectors z and

    p, and the gain in the scalark.

    [ z, p, k] = but t er ( n, Wn, 'ftype') designs a highpass, lowpass, or bandstop filter, where the

    string 'ftype' is one of the following:

  • 7/27/2019 MANUAL 19032012

    27/33

    ' hi gh' for a highpass digital filter with normalized cutoff frequency Wn

    ' l ow' for a lowpass digital filter with normalized cutoff frequency Wn

    ' stop' for an order2*n bandstop digital filter ifWn is a two-element vector, Wn = [ w1

    w2] . The stopband is w1 < < w2.

    Cutoff frequency is that frequency where the magnitude response of the filter is . For

    but t er , the normalized cutoff frequency Wn must be a number between 0 and 1, where 1corresponds to theNyquist frequency, radians per sample.

    IfWn is a two-element vector, Wn = [ w1 w2] , but t er returns an order2*n digital bandpass filter

    with passbandw1

  • 7/27/2019 MANUAL 19032012

    28/33

    [ z, p, k] = but t er ( n, Wn, ' ftype' , ' s ' ) designs a highpass, lowpass, or bandstop filter using

    the ftype values described above.

    With different numbers of output arguments, but t er directly obtains other realizations of theanalog filter. To obtain the transfer function form, use two output arguments as shown below:

    [ b, a] = but t er ( n, Wn, ' s' ) designs an ordern lowpass analog Butterworth filter with angularcutoff frequency Wn rad/s. It returns the filter coefficients in the length n+1 row vectors b anda,

    in descending powers ofs, derived from this transfer function:

    [ b, a] = but t er( n, Wn, 'ftype', ' s ' ) designs a highpass, lowpass, or bandstop filter using the

    ftype values described above.

    To obtain state-space form, use four output arguments as shown below:

    [ A, B, C, D] = but t er ( n, Wn, ' s' ) or

    [ A, B, C, D] = but t er( n, Wn, ' ftype' , ' s ' ) where A, B, C, andDare

    andu is the input,x is the state vector, andy is the output.

    Examples

    Highpass Filter

    For data sampled at 1000 Hz, design a 9th-order highpass Butterworth filter with cutofffrequency of 300 Hz, which corresponds to a normalized value of 0.6:

    [ z, p, k] = but t er ( 9, 300/ 500, ' hi gh' ) ;[ sos, g] = zp2sos( z, p, k) ; % Conver t t o SOS f or mHd = df i l t . df 2t sos( sos, g) ; % Cr eat e a df i l t obj ecth = f vtool ( Hd) ; % Pl ot magni t ude r esponseset ( h, ' Anal ysi s' , ' f r eq' ) % Di spl ay f r equency r esponse

  • 7/27/2019 MANUAL 19032012

    29/33

    Limitations

    In general, you should use the [ z ,p, k] syntax to design IIR filters. To analyze or implement

    your filter, you can then use the [ z ,p, k] output withzp2sosand an sosdf i l t structure. Forhigher order filters (possibly starting as low as order 8), numerical problems due to roundoff

    errors may occur when forming the transfer function using the [ b, a] syntax. The following

    example illustrates this limitation:

    n = 6; Wn = [ 2. 5e6 29e6] / 500e6;f t ype = ' bandpass' ;

    % Transf er Funct i on desi gn[ b, a] = but t er ( n, Wn, f t ype) ;h1=df i l t . df 2( b, a) ; % Thi s i s an unstabl e f i l t er.

    % Zer o- Pol e- Gai n desi gn[ z, p, k] = but t er ( n, Wn, f t ype) ;[ sos, g] =zp2sos( z, p, k);h2=df i l t . df 2sos( sos, g) ;

    % Pl ot and compar e t he resul t s

  • 7/27/2019 MANUAL 19032012

    30/33

    hf vt =f vt ool ( h1, h2, ' Fr equencyScal e' , ' l og' ) ;l egend( hf vt , ' TF Desi gn' , ' ZPK Desi gn' )

    Algorithm

    but t er uses a five-step algorithm:

    1. It finds the lowpass analog prototype poles, zeros, and gain using the but t ap function.

    2. It converts the poles, zeros, and gain into state-space form.

    3. It transforms the lowpass filter into a bandpass, highpass, or bandstop filter with desiredcutoff frequencies, using a state-space transformation.

    4. For digital filter design, but t er usesbi l i near to convert the analog filter into a digitalfilter through a bilinear transformation with frequency prewarping. Careful frequency

    adjustment guarantees that the analog filters and the digital filters will have the same

    frequency response magnitude at Wn orw1 andw2.

  • 7/27/2019 MANUAL 19032012

    31/33

    5. It converts the state-space filter back to transfer function or zero-pole-gain form, asrequired.

    See Also

    bessel f,but t ap,buttord,cheby1,cheby2,el l i p,maxf l at

    Procedure:

    1. Double click on MATLAB icon on the desktop.2. Click on File > New > M-File.3. Type the program in the M-File Editor.4. Save the file with a relavant name.5. Run the program by clicking on the Run Icon in the toolbar and observe the output.

    Program :[ It should be computer print ]

    As above.

    Conclusion :By using MATLAB Iir filter desgin is studied.

  • 7/27/2019 MANUAL 19032012

    32/33

    ztrans

    z-transform

    Syntax

    F = zt r ans( f )F = zt r ans( f , w)F = zt r ans( f , k, w)

    Description

    F = zt r ans( f ) is the z-transform of the scalar symbol f with default independent variable n.The default return is a function ofz.

    The z-transform off is defined as

    where n is f's symbolic variable as determined by symvar . Iff = f ( z) , then ztr ans(f ) returnsa function ofw.

    F= F(w)

    F = zt r ans( f , w) makes F a function of the symbol winstead of the default z.

    F = zt r ans( f , k, w) takes f to be a function of the symbolic variable k.

    Examples

  • 7/27/2019 MANUAL 19032012

    33/33

    Z-Transform MATLAB Operation

    f(n) = n syms n;f = n 4;ztr ans(f )ans =

    ( z 4 + 11*z 3 + 11*z 2 + z) / ( z - 1) 5

    g(z) = az syms a z;g = a z;zt r ans( g)ans =- w/ ( a - w)

    f(n) = sin(an) syms a n w;f = si n( a*n) ;zt r ans( f , w)ans =( w*si n( a) ) / ( w 2 - 2*cos( a) *w + 1)