Home
Signal Processing Toolbox User's Guide
Contents
1. v 1 f m Py 1 38 Linear System M odels The toolbox function t f 2 atc accepts an FIR or IIR filter in polynomial form and returns the corresponding reflection coefficients An example IIR filter in polynomial form is a 1 0000 0 6149 0 9899 0 0000 0 0031 0 0082 This filter s lattice reflection coefficient representation is k tf2latc a 0 3090 0 9800 0 0031 0 0081 0 0082 The magnitude of the reflection coefficients provides an easy stability check for a filter If all the reflection coefficients corresponding to a polynomial have magnitude less than 1 all of that polynomial s roots are inside the unit circle The function at c2tf calculates the polynomial coefficients for a filter from its lattice reflection coefficients Given the reflection coefficient vector k above the corresponding polynomial form is a latc2tf k a 1 0000 0 6149 0 9899 0 0000 0 0031 0 0082 The lattice or lattice ladder coefficients can be used to implement the filter using the function atcfilt Convolution Matrix In signal processing convolving two vectors or matrices is equivalent to filtering one of the input operands by the other This relationship permits the representation of a digital filter as a convolution matrix Given any vector the toolbox c onv mt x function generates a matrix whose inner product with another vector is equivalent to the convolution of the two
2. to change the line style order 5 23 5 Interactive Tools 5 24 Signal Browser Settings The Signal Browser preferences let you set optional x axis and y axis labels enable and disable the display of the rulers and the panner and toggle zoom persistence 3 Peghe rence jur SPI o X Label Y Label Type in a string for the x axis label and the y axis label in the Signal Browser The default is Ti me for the x axis Rulers Click in the check box to display checked or hide unchecked the ruler buttons and the ruler panel in the Signal Browser See Ruler Controls on page 5 32 for details on using the rulers in the Signal Browser Panner Click in the check box to display checked or hide unchecked the panner in the Signal Browser See Panner Display on page 5 51 for details on using the panner in the Signal Browser Stay in Zoom mode After Zoom Click in the check box to enable checked or disable unchecked zoom persistence in the Signal Browser See Zoom Controls on page 5 30 for details on zoom controls in the Signal Browser Using SPTool Spectrum Viewer Settings The Spectrum Viewer preferences let you set axis parameters enable and disable the display of the rulers and toggle zoom persistence Magnitude Axis Scaling Specifies the scaling units for the magnitude y axis in the Spectrum Viewer Scaling units can be dB or linear Click in the pop up menu and dra
3. 1 3 Graphical User Interface GUI 0 cee ees 1 3 Extensibility 0 00 c cee eee 1 3 Representing Signals 0 cece eens 1 4 Vector Representation 0006 c cece 1 4 Waveform Generation Time Vectors and Sinusoids 1 6 Common Sequences Unit Impulse Unit Step and Unit Ramp 1 7 Multichannel SignalS 0 00 00 eee ee 1 7 Common Periodic Waveforms 0060e cence eee 1 8 Common Aperiodic Waveforms 0020 cece eee 1 9 The pulstran Function 0 0000 cee ee 1 10 The Sinc Function 00 00 eee 1 10 The Dirichlet Function 0 00000 cee eee 1 12 Contents Contents Working with Data 0 00 1 13 Filter Implementation and Analysis 1 14 Convolution and Filtering 000 cece eee ee 1 14 Filters and Transfer Functions 0 0 e eee eeee 1 15 Filter Coefficients and Filter Names 1 15 Filtering with the filter Function 0 000005 1 15 filter Function Implementation and Initial Conditions 1 17 Other Functions for Filtering 1 19 Multirate Filter Bank Implementation 1 19 Anti Causal Zero Phase Filter Implementation 1 20 Frequency Domain Filter Implementation 1 22 Impulse Response 0 0 cece cece eee eens 1 23 Frequency Response
4. 5 89 5 Interactive Tools 5 90 Fa EER rns bibeh jca Pequency Parga Pupeny e E Menus File Menu Use Close from the File menu to close the Spectrum Viewer All spectrum selection and ruler information will be lost Settings you changed using the Preferences window in SPTool are saved and used the next time you open the Spectrum Viewer Options Menu Use these options to change scaling and range parameters for plots in the Spectrum Viewer Click on the option you want to edit and drag to select a value The options include e Magnitude Scale Scaling for the magnitude plot may be dB or linear e Frequency Range Therange for the frequency axis may be 0 Fs 2 0 Fs or Fs 2 Fs 2 where Fs is the sampling frequency If multiple spectra are displayed the value of Fs is the maximum of all the sampling frequencies Fs iS not defined for the case of a spectrum whose signal iS lt None gt thatis a spectrum whose associated signal has been deleted from SPT ool In this case a value twice the highest frequency in the spectrum s frequency vector is chosen The frequency range cannot be negative if Frequency Scale is set to log e Frequency Scale Scaling for the frequency axis may be linear or log Window Menu Use the window menu to select a currently open MATLAB Figure window Signal ID Panel This pane displays information about the signal linked to the currently selected spectrum The information includ
5. Purpose Syntax Description Example Algorithm 6 72 Convolution matrix A convmt x c n A convmt x r n A convolution matrix is a matrix formed from a vector whose inner product with another vector is the convolution of the two vectors A convmtx c n wherec is alength m column vector returns a matrix A of size m n 1 by n The product of A and another column vector x of length n is the convolution ofc with x A convmtx r n wherer is alength m row vector returns a matrix A of size n by m n 1 Theproduct of A and another row vector x of length n is the convolution ofr with x Generate a simple convolution matrix h 12 32 1 convmt x h 7 ans ooo CoOCO OF ooococor MN Soo CO OF Nw SO COrFPN Ww Pp SOF N WN PE SCOrFPNWNH o FPNMWNPH OO NWN F OOO WNPF DOGO NF OOOO eo od Note that conv mt x handles edge conditions by zero padding In practice it is more efficient to compute convolution using y conv c x than by using a convolution matrix n length x y convmtx c n x convmt x uses the function t oep i tz to generate the convolution matrix convmtX amp See Also conv Convolution and polynomial multiplication convn N dimensional convolution see the online MATLAB Function Reference conv2 Two dimensional convolution df t mt x Discrete Fourier transform matrix 6 73 corrcoef Purpose Syntax Description See Also 6 74 Correlation coefficie
6. Algorithm Diagnostics See Also References st mcb attempts to minimize the squared error between the impulse response x of b z a z and the input signal x min yi xD xP a b i 0 stmcb iterates using two steps 1 It prefiltersx andu using 1 a z 2 It solves a system of linear equations for b anda using stmcb repeats this process ni t er times No checking is donetoseeif theb and a coefficients have converged in fewer than nit er iterations Ifx andu have different lengths st mcb gives the following error message X and U must have same length levinson Levinson Durbin recursion Ipc Linear prediction coefficients oe Compute the prediction error estimate of an output error model see System Identificati on Toolbox User s Guide prony Prony s method for time domain IHR filter design 1 Steiglitz K andL E McBride A Technique for the dentification of Linear Systems IEEE Trans Automatic Control Vol AC 10 1965 Pgs 461 464 2 Ljung L System Identification Theory for the User Englewood Cliffs NJ Prentice Hall 1987 Pg 297 6 303 strips Purpose Syntax Description 6 304 Strip plot strips x strips x n strips x sd Fs strips x sd Fs scale strips x plots vector x in horizontal strips of length 250 If x is a matrix strips x plots each column of x The left most column column 1 is the top horizontal strip stri stri ps ps x n
7. Filter Requirements and Specification The Signal Processing Toolbox provides functions that support a range of filter design methodologies This chapter explains how toapply the filter design tools to Infinite Impulse Response IIR and Finite Impulse Response FIR filter design problems The goal of filter design is to perform frequency dependent alteration of a data sequence A possible requirement might be to remove noise above 30 Hz from a data sequence sampled at 100 Hz A morerigorous specification might call for a specific amount of passband ripple stopband attenuation or transition width A very precise specification could ask to achieve the performance goals with the minimum filter order or it could call for an arbitrary magnitude shape or it might require an FIR filter Filter design methods differ primarily in how performance is specified For loosely specified requirements as in the first case above a Butterworth IIR filter is often sufficient To design a fifth order 30 Hz lowpass Butterworth filter and apply it to the data in vector x b a butter 5 30 50 y filter b a x The second input argument tobutt er indicates the cutoff frequency normalized to half the sampling frequency the Nyquist frequency Frequency Normalization in the Signal Processing Toolbox All of the filter design functions operate with normalized frequencies so they do not require the system sampling rate as an extra input arg
8. Returning to the original polynomials bb k poly q bb 2 0000 3 0000 4 0000 aa poly p 1 0000 3 0000 3 0000 1 0000 Note that b anda in this case represent the transfer function 1 2 3 2 H z 2 Z Z 2z Z Z 1432 2437 7 z 24327 3241 Forb 2 3 4 theroots function misses the zero for z equal to 0 In fact it misses poles and zeros for z equal to 0 whenever theinput transfer function has more poles than zeros or vice versa This is acceptable in most cases To circumvent the problem however simply append zeros to make the vectors the same length before using ther oot s function for example b b 0 State Space It is always possible to represent a digital filter or a system of difference equations as a set of first order difference equations In matrix or state space form you can write the equations as x n 1 Ax n Bu n y n Cx n Du n whereu is the input x is the state vector andy is the output For single channel systems A is an m by m matrix where m is the order of the filter B is a column vector C is a row vector andD is a scalar State space notation is especially convenient for multichannel systems where input u and output y become vectors and B C and D become matrices State space representation extends easily to the MATLAB environment In MATLAB A B C andD are rectangular arrays MATLAB treats them as individual variables Linear System M odels Taking thez transform
9. n 3 Chebyshev Type Lowpass Filter 1 ie L 50 100 150 L L L L L L 200 250 300 350 400 450 Frequency Hertz 500 Phase degrees L n 1 50 100 150 6 42 L h 1 1 i L 200 250 300 350 400 450 500 cheblord Next design a bandpass filter with a passband of 100 Hz to 200 Hz less than 3 dB of attenuation throughout the passband and 30 dB stopbands 50 Hz out on both sides of the passband Wp 100 200 500 Ws 50 250 500 Rp 3 Rs 30 n Wn cheblord Wp Ws Rp Rs n Wn 0 2000 0 4000 b a chebyl n Rp Wn freqz b a 512 1000 n 4 Chebyshev Type Bandpass Filter 7 0 T T 2007 Magnitude Response dB L L L L t L L L 0 50 100 150 200 250 300 350 400 450 500 Frequency Hertz Phase degrees i A fo oO l L L L ii L L L i 50 100 150 200 250 300 350 400 450 500 Frequency Hertz Algorithm cheblord usesthe Chebyshev lowpass filter order prediction formula described in 1 The function performs its calculations in the analog domain for both analog and digital cases For the digital case it converts the frequency parameters to the s domain before the order and natural frequency estimation process then converts them back to the z domain cheblord See Also References 6 44 cheblord initially develops a lowpass filter prototype by transforming the passband frequencies of the desired filt
10. 00 cece eee eee 1 24 Digital Domain aa AA aa a ani 1 24 Analog Domai krr pene a PEE os EEEE ae Aa E 1 26 Magnitude and Phase 000 cece eee eee eee 1 26 Del AY iisi ey ee id spake etal cade Ped eed 1 28 Zero Pole Analysis 0 000s 1 30 Linear System Models 0 00 c cece eens 1 32 Discrete Time System Models 0 000 e eee eee ee 1 32 Transfer FUNCION 00 00 1 32 Zero POleGalh 2d eee swivel eeaGuneda poeta 1 33 State Space i gia a mia a hte eda la wy be a ee 1 34 Partial Fraction Expansion ResidueForm 1 35 Second Order Sections SOS 000 0 eee eee 1 37 Lattice Structure 0 0 2 0 0c cece 1 37 Convolution Matrix 0 0 00 c eee 1 39 Continuous Time System Models 0000 cee eee 1 40 Linear System Transformations 0 00e eee eee 1 41 Discrete Fourier Transform 000 1 43 References 2 040654 chase nd bs Sos hee BE ea ads 1 46 2 Filter Requirements and Specification 2 2 IHR Filter Design 2 2 03 5 226 pate Ge heaties oe hans See Ses 2 4 Classical IIR Filter Design Using Analog Prototyping 2 6 Complete Classical IIR Filter Design 2 0 5 2 6 Designing IIR Filters to Frequency Domain Specifications 2 7 Comparison of Classical IIR Filter Types 2 8 Butterworth Filter 0 00000 eee eee 2 8 Chebyshev Type Filte
11. NOTE If the band ripples are specified as unequal the smallest one is used since the Kaiser window method is constrained to give filters with equal ripple heights in all the passbands and stopbands n Wn beta ftype kaiserord f a dev finds the approximate order n normalized frequency band edges Wn and weights that meet input specifications f a anddev f is a vector of band edges and a is a vector specifying the desired amplitude on the bands defined by f The length off is twice the length of a minus 2 Together f anda define a desired piecewise constant response function dev is a vector thesame size asa that specifies the maximum allowable error or deviation between the frequency response of the output filter and its desired amplitude for each band fir1 can usethe resulting order n frequency vector Wn multiband magnitude typef type and the Kaiser window parameter beta Theft ype stringis intended for use with f i r 1 itis equal to hi gh for a highpass filter and st op for a bandstop filter For multiband filters it can be equal to dc 0 when the first band is a stopband starting at f O or dc 1 when thefirst band is a passband Todesign a filter b that approximately meets the specifications given bykai ser parametersf a anddev b firl n Wn kaiser ntl beta ftype noscale kaiserord Algorithm n Wn beta ftype kaiserord f a dev Fs specifies a sampling frequency Fs If not present
12. Windows bartlett Bartlett window blackman Blackman window boxcar Rectangular window chebwin Chebyshev window hammi ng Hamming window hanni ng Hanning window kaiser triang Kaiser window Triangular window 6 7 6 Reference 6 8 Parametric Modeling invfreqs invfreqz evinson pe prony st mcb Continuous time analog filter identification from frequency data Discrete time filter identification from frequency data Levinson Durbin recursion Linear prediction coefficients Prony s method for time domain IIR filter design Linear model using Steiglitz McBride iteration Specialized Operations cceps cpl xpair deci mate deconv demod detrend dpss dpssclear dpssdir dpssload dpsssave icceps Complex cepstral analysis Group complex numbers into complex conjugate pairs Decrease the sampling rate for a sequence decimation Deconvolution and polynomial division Demodulation for communications simulation Remove linear trends Discrete prolate spheroidal sequences Slepian sequences Remove discrete prolate spheroidal sequences from database Discrete prolate spheroidal sequences database directory Load discrete prolate spheroidal sequences from database Save discrete prolate spheroidal sequences in database Inverse complex cepstrum Specialized Operations interp medfilt1 modulate polystab rceps resample specgram
13. given the numerator and denominator coefficients in vectorsb anda grpdel ay returns both gd the group delay and w a vector containing then frequency points in radians gr pdel ay evaluates the group delay atn points equally spaced around the upper half of the unit circle sow containsn points between 0 and z A value for n that is an exact power of two allows fast computation using an FFT algorithm gd f grpdelay b a n Fs specifies a positive sampling frequency Fs in Hertz It returns a length n vector f containing the actual frequency points at which the group delay is calculated alsoin Hertz f containsn points between OandFs 2 6 165 grpdelay Examples 6 166 gd w grpdelay b a n whole and gd f grpdelay b a n whole Fs usen points around the whole unit circle from 0 to 2x or from OtoFs gd grpdelay b a w and gd grpdelay b a f Fs return the group delay evaluated at the points in w in radians orf in Hertz respectively whereFs is the sampling frequency in Hertz grpdel ay with no output arguments plots the group delay versus frequency in the current figure window grpdel ay works for both real and complex input systems Plot the group delay of Butterworth filter b z a z b a butter 6 0 2 grpdel ay b a 128 Group delay in samples L L L L L L 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 Normalized frequency Nyquist 1 0 L fi fi grpdelay Al
14. 0000 DONNOK 2732 9549 2282 8648 3183 1 Signal Processing Basics Waveform Generation Time Vectors and Sinusoids Therearea variety of toolbox functions for generating 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 vector is tee Ore OORT where MATLAB s colon operator creates a 1001 element row vector that represents time running from zero to one second in steps of one millisecond The transpose operator changes the row vector into a column the semicolon tells MATLAB to compute but not display the result Given t you can create a sample signal y consisting of two sinusoids one at 50 Hz and oneat 120 Hz with twice 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 normally distributed white noise to the signal and graph the first fifty points using yn y 0 5 randn size t plot t 1 50 yn 1 50 L L L ie 0 0 01 0 02 0 03 0 04 0 05 W aveform G eneration Time Vectors and Sinusoids Common Sequences Unit Impulse Unit Step and Unit Ramp Since MATLAB is a programming language an endless variety of different signals is possible Here are some statements that generate several commonly used sequences including the unit impulse unit step and unit ramp functions
15. Englewood Cliffs NJ Prentice Hall 1989 Pgs 363 370 2 J ackson L B Digital Filters and Signal Processing Second Ed Boston Kluwer Academic Publishers 1989 Pgs 319 324 6 296 ss2tf Purpose Syntax Description Algorithm See Also State space to transfer function conversion num den ss2tf a b c d iu ss2tf converts a state space representation of a given system to an equivalent transfer function representation num den ss2tf a b c d iu returns the transfer function mos aeqia BED den s of the system x Ax Bu y Cx Du fromthei u th input Vector den contains the coefficients of the denominator in descending powers of s The numerator coefficients are returned in array num with as many rows as there are outputs y The function t f 2s s is the inverse of ss2tf ss2tf alsoworks with systems in discretetime in which case it returns the z transform representation ss2tf usespol y tofind the characteristic polynomial det sl A and the equality H s e t Ay tp T A bo det st A det sI A SS2Zp State space to zero pole gain conversion tf2ss Transfer function to state space conversion tf2zp Transfer function to zero pole gain conversion zp2ss Zero pole gain to state space conversion zp2tf Zero pole gain to transfer function conversion 6 297 ss2zp Purpose Syntax Description 6 298 State space to zero pole gain conversion Z p k ss2zp A B C D iu
16. b a chebyl 4 1 4 7 bandpass Chebyshev type b a cheby2 6 60 8 high highpass Chebyshev type II b a ellip 3 1 60 4 7 stop bandstop elliptic To design an analog filter perhaps for simulation use a trailing s and specify cutoff frequencies in radians second b a butter 5 4 s analog Butterworth filter All filter design functions return a filter in the transfer function zero pole gain or state space linear system model representation depending on how many output arguments are present Designing IIR Filters to Frequency Domain Specifications This toolbox provides order selection functions that calculate the minimum filter order that meets a given set of requirements Filter Type Order Estimation Function Butterworth n Wn buttord Wp Ws Rp Rs Chebyshev type n Wn cheblord Wp Ws Rp Rs Chebyshev type I n Wn cheb2ord Wp Ws Rp Rs Elliptic n Wn ellipord Wp Ws Rp Rs These are useful in conjunction with the filter design functions Suppose you want a bandpass filter with a passband from 1000 to 2000 Hz stopbands starting 500 Hz away on either side a 10 KHz sampling frequency at most 1 dB 2 Filter Design of passband ripple and at least 60 dB of stopband attenuation To meet these specifications with thebut ter function n Wn buttord 1000 2000 5000 500 2500 5000 1 60 n 12 Wn 0 1951 0 4080 b a butter n Wn An elliptic filter
17. cl lags xcorr x y cl mat2str cl 2 lags cl 124i 8 9e 016 154i 8 22 10 5 i 12 6 i 8 9e 016 lags 2 1 0 1 2 c2 conj fliplr xcorr y x c2 mat 2str c2 2 12 i 8 9e 016 15 i 8 22 10 5ti 12 6 1 8 9e 016 For the case where input argument x is a matrix the output columns are arranged so that extracting a row and rearranging it into a square array 6 326 xCcorr Algorithm Diagnostics produces the cross correlation matrix corresponding to the lag of the chosen row For example the cross correlation at zero lag can be retrieved by randn seed 0 X randn 2 2 M P size X c xcorr X c0 zeros P cO c M Extract zero lag row c0 1 7500 0 3079 0 3079 0 1293 You can calculate the matrix of correlation coefficients that the MATLAB function corrcoef generates by substituting c xcov X coef in the last example The function xcov subtracts the mean and then calls Xcorr Usef ft shi ft tomovethe second half of the sequence starting at the zeroth lag to the front of the sequence f f t shi ft swaps the first and second halves of a sequence For more information on estimating covariance and correlation functions see 1 and 2 There must be at least one vector input argument otherwise xcorr gives the following error message lst arg must be a vector or matrix The string option must be the last argument otherwise xcorr gives the follo
18. t 0 001 1 y 1 zeros 99 1 impulse y ones 100 1 step filter assumes 0 initial cond y t ramp y t 2 y square 4 t All of these sequences are column vectors the last three inherit their shapes fromt Multichannel Signals Use standard MATLAB array syntax to work with multichannel signals For example a multichannel signal consisting of the last three signals generated above is z t t 2 square 4 t You can generate a multichannel unit sample function using the outer product operator F or example a six element column vector whose first element is one and whose remaining five elements are zeros iS a 1 zeros 1 5 To duplicate column vector a into a matrix without performing any multiplication use MATLAB s colon operator and theones function c a ones 1 3 1 Signal Processing Basics Common Periodic Waveforms The toolbox provides functions for generating widely used periodic waveforms e sawtooth generates a sawtooth wave with peaks at 1 and a period of 22 An optional wi dt h parameter specifies a fractional multiple of 2x at which the signal s maximum occurs e square generates a square wave with a period of 2x An optional parameter specifies duty cycle the percent of the period for which the signal is positive Togenerate 1 5 seconds of a 50 Hz sawtooth wave with a sample rate of 10 kHz and plot 0 2 seconds of the generated waveform use Fs 10000
19. t QO 1 Fs 1 5 x sawtooth 2 pi 50 t plot t x axis 0 0 2 1 1 1 0 57 4 0 5 1 W aveform G eneration Time Vectors and Sinusoids Common Aperiodic Waveforms The toolbox also provides functions for generating several widely used aperiodic waveforms e gauspuls generates a Gaussian modulated sinusoidal pulse with a specified time center frequency and fractional bandwidth Optional parameters return in phase and quadrature pulses the RF signal envelope and the cutoff time for the trailing pulse envelope e chirp generates a linear swept frequency cosine signal An optional parameter specifies alternative sweep methods An optional parameter p hi allows initial phase to be specified in degrees To compute 2 seconds of a linear chirp signal with a sample rate of 1 kHz that starts at DC and crosses 150 Hz at 1 second use t 0 1 1000 2 y chirp t 0 1 150 To plot the spectrogram use specgram y 256 1000 256 250 500 450 Frequency 1 9 1 Signal Processing Basics 1 10 The pulstran Function Thepul st ran function generates pulse trains from either continuous or sampled prototype pulses The following example generates a pulse train consisting of the sum of multiple delayed interpolations of a Gaussian pulse The pulse train is defined to havea sample rate of 50 kHz a pulsetrain length of 10 ms and a pulse repetition rate of 1 kHz D sp
20. 0 0 0 0 00 cece eee eee 2 41 Impulselnvariance 06 0 0 c eee 2 41 Bilinear Transformation 0 0 ccc eee eee ee 2 42 References 2 2020 08 ee es eb gS E 2 45 Statistical Signal Processing 3 Correlation and Covariance 00050 3 2 Bias and Normalization 0 0 00 ccc eee eee 3 3 Multiple Channels 00000 ee 3 4 Spectral Analysis 0 0 c cece eee 3 5 Welch s Method sci s he a a eh eA OR UY a 3 6 Power Spectral Density Function 0 45 3 10 Bias and Normalization in Welch s Method 3 11 Parseval s Relation nunana ccc cece ees 3 13 Cross Spectral Density Function 0005 3 13 Confidence IntervalS 0 0 0 cece eee eee 3 14 Transfer Function Estimate 00 00 eae 3 14 Coherence FUNCLION eroderen ae eee 3 15 Multitaper Method 00 00 c eee eee ee 3 16 Yule Walker AR Method 0 0 00 ccc eee eee eee 3 19 Buro Method 2 05 08 Seats i es meiieh eee a eeetware Lees 3 20 MUSIC and Eigenvector Analysis Methods 3 22 Eigenanalysis Overview 0 00 cece eee ee 3 23 Controlling Subspace Thresholds 000eeeee 3 24 iv Contents References 2 3 6 533 heen ah se ee he ea 3 26 4 WINdOWS 3 02 53 04 Sek i Sand ea Pg ete le a Aas 4 2 Basi Shapes scier nisin eke Magda ted sedans amp 4 2 Generalized Cosine Windows 000 cece ee eee
21. 2 9 2 Filter Design 2 10 Chebyshev Type II Filter The Chebyshev type I filter minimizes the absolute difference between the ideal and actual frequency response over the entire stopband by incorporating an equal ripple of Rs dB in the stopband Passband response is maximally flat The stopband does not approach zero as quickly as the type filter and does not approach zero at all for even valued n The absence of ripple in the passband however is often an important advantage H jQ 108 at Q 1 1 Magnitude 0 2 10 Frequency rad sec Elliptic Filter Elliptic filters are equiripple in both the passband and stopband They generally meet filter requirements with thelowest order of any supported filter type Given a filter order n passband rippleRp in decibels and stopband ripple IIR Filter Design Rs in decibels elliptic filters minimize transition width H jQ 10 RP at Q 1 0 87 S D T Magnitude AEn 0 1 0 1 10 10 10 Frequency rad sec Bessel Filter Analog Bessel lowpass filters have maximally flat group delay at zero frequency and retain nearly constant group delay across the entire passband Filtered signals therefore maintain their waveshapes in the passband frequency range Frequency mapped and digital Bessel filters however do not have this maximally flat property this toolbox supports only the analog case for the complete Bessel filt
22. 3 dB Wn must be between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency b maxflat nb sym Wn is asymmetric FIR Butterworth filter nb must be even and Wn is restricted to a subinterval of 0 1 The function raises an error if Wn is specified outside of this subinterval b a b1 b2 maxflat nb na Wn returns two polynomials b1 and b2 whose product is equal to the numerator polynomial b that is b conv b1 b2 b1 contains all thezeros at z 1 andb2 contains all the other zeros maxflat nb na Wn design_flag enables you to monitor the filter design wheredesign_flag is e trace for a textual display of the design table used in the design e plots for plots of the filter s magnitude group delay and zeros and poles e both for both the textual display and plots 6 215 max flat Examples Algorithm See Also References 6 216 nb 10 na 2 Wn 0 2 pi b a b1 b2 maxflat nb na Wn plots Frequency response 1 J me 0 5 J D Oo OF 1 L L L 0 0 2 0 4 0 6 0 8 1 Pole zero plot w p Group delay 5 1 eS a or S s x 2 SR 4 0 5 K 7 F O I o 23 g 0 lt deg 40 3 o l amp 2 05 a Lee 1 i Sooni 0 1 0 1 0 0 5 1 Real w p The method consists of the use of formulae polynomial root finding anda transformation of polynomial roots butter Butterworth analog and digital filter desi
23. Example Importing Signal Data from a MAT File on page 5 5 for more information Export Select Export from the File menu to export signals filters and spectra to the MATLAB workspace as structure variables See Saving Signal Data on page 5 53 Saving Filter Data on page 5 69 and Saving Spectrum Data on page 5 98 for complete information Save Session Select Save Session and Save Session As from the File menu to save the current session Save Session overwrites the existing session file Save Session As saves the current session with a name you specify An SPTool session is saved in a MAT file with an spt extension Preferences Select Preferences from the File menu to customize preferences for the behavior of all the Signal Processing GUI tools See Customizing Preferences on page 5 21 for a complete discussion Close Select Close from the File menu to close SPTool and all other active Signal Processing GUI tools SPTool prompts you to save if you have not recently saved the current session When you close SPTool all signal and filter customization and ruler information set in any of the GUI tools arelost Settings you changed and saved using the Preferences window in SPTool are saved and used the next time you open SPT ool 5 7 5 Interactive Tools 5 8 Help Menu Overview Select Overview from the File menu to get general help on SPTool and the Signal Processing Toolbox GU
24. See Also References Find how many DCT coefficients represent 99 of the energy in a sequence x 1 100 50 cos 1 100 2 pi 40 XE deni XX ind sort abs X ind fliplr ind i 1 while norm X ind 1 i zeros 1 100 i norm X lt 99 iY Bei E end 3 fft One dimensional fast Fourier transform idct Inverse discrete cosine transform dct 2 Two dimensional DCT see mage Processing T ool box User s Guide idct2 Two dimensional inverse DCT see mage Processing Toolbox User s Guide 1 ain A K Fundamentals of Digital mageProcessing Englewood Cliffs NJ Prentice Hall 1989 2 Pennebaker W B and J L Mitchell J PEG Still I mage Data Compression Standard New York NY Van Nostrand Reinhold 1993 Chapter 4 6 93 decimate Purpose Syntax Description Example 6 94 Decrease the sampling rate for a sequence decimation deci mat e x r deci mate x r n decimate x r fir deci mate x r n fir Sate Sa SA eE Decimation reduces the original sampling rate for a sequence to a lower rate It is 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 of x by a factor r The decimated vector y isr times shorter in length than the input vector x By default deci mate employs an eighth order lowpass Cheby
25. gauspuls cutoff 50e3 0 6 40 t tc le 6 tc yi gauspuls t 50e3 0 6 plot t yi 1 0 8F 0 6 0 44 0 27 4 OF 0 2 0 4 0 6 8 2 0 2 4 x10 See Also chirp Swept frequency cosine generator cos Cosine of vector matrix elements see the online MATLAB Function Reference diric Dirichlet or periodic sinc function pulstran Pulse train generator rectpuls Sampled aperiodic rectangle generator sawtooth Sawtooth or triangle wave generator sin Sine of vector matrix elements See the online MATLAB Function Reference sinc Sinc or sin xt rt function Square Square wave generator tripuls Sampled aperiodic triangle generator 6 164 grpdelay Purpose Syntax Description Average filter delay group delay gd w grpdelay b a n gd f grpdelay b a n Fs gd w grpdelay b a n whole gd f grpdelay b a n whole Fs gd grpdelay b a w gd grpdelay b a f Fs grpdel ay b a The group dday of a filter is a measure of the average delay of the filter as a function of frequency It is the negative first derivative of the phase response of the filter If the complex frequency response of a filter is H then the group delay is d0 w Oo where o is frequency and is the phase angle of H 8 gd w grpdelay b a n returns then point group delay Tg of the digital filter Bz _ b bQ z_ nb Iz AZ al a a nat Iz A z
26. ss2zp converts a state space representation of a given system to an equivalent zero pole gain representation The zeros poles and gains of state space systems represent the transfer function in factored form Z p k ss2zp A B C D iu calculates the transfer function in factored form 205 _ p s 2D 22 5 2 H s P s s p s p 2 s p n of the system x Ax Bu y Cx Du from thei u th input Returned column vector p contains the pole locations of the denominator coefficients of the transfer function Array Z contains the numerator zeros in its columns with as many columns as there are outputs y Column vector k contains the gains for each numerator transfer function The function zp2ss is the inverse of ss2zp ss2zp also works with systems in discrete time in which case it returns the z transform representation The input state space system must be real ss2zp Example Algorithm Here are two ways of finding the zeros poles and gains of a system num 2 3 den 1 0 4 1 z p k tf2zp num den Z 1 5000 p 0 2000 0 9798i 0 2000 0 9798i k 2 A B C D tf2ss num den z p k ss2zp A 8B C D 1 Z 1 5000 p 0 2000 0 9798i 0 2000 0 9798i k 2 ss2zp finds the poles from the eigenvalues of the A array The zeros are the finite solutions to a generalized eigenvalue problem z eig A B C D diag ones 1 n 0 In many situati
27. 0 and with a default width of 1 Notethat the interval of non zero amplitude is defined to be open on the right that is rect puls 0 5 1 whilerectpuls 0 5 0 y rectpuls t w generates a rectangle of width w rect puls is typically used in conjunction with the pulse train generating function pul stran chirp Swept frequency cosine generator cos Cosine of vector matrix elements See the online MATLAB Function Reference diric Dirichlet or periodic sinc function gauspuls Gaussian modulated sinusoidal pulse generator pulstran Pulse train generator sawtooth Sawtooth or triangle wave generator sin Sine of vector matrix elements see the online MATLAB Function Reference sinc Sinc or sin xt rt function Square Square wave generator tripuls Sampled aperiodic triangle generator remez Purpose Syntax Description Parks McClellan optimal FIR filter design b remez n f a b remez n f a w b remez n f a ftype b remez n f a w ftype b remez lgrid b remez n f fresp w b remez n f fresp w ftype b remez n f fresp pl p2 w b remez n f fresp pl p2 w ftype b delta remez b delta opt remez remez designs a linear phase FIR filter using the Parks McClellan algorithm 1 The Parks McClellan algorithm uses the Remez exchange algorithm and Chebyshev approximation theory to design filters with an optimal fit between the de
28. 2 400 J 500 L L L L L 1 L L L 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 freqz uses an FFT algorithm when argument n is present It computes the frequency response as the ratio of the transformed numerator and denominator coefficients padded with zeros to the desired length h fft b n fft a n If n is not a power of two the FFT algorithm is not as efficient and may cause long computation times When a frequency vector w or f is present or ifn is less than max length b length a freqz evaluates the polynomials at each 6 161 freqz See Also 6 162 frequency point using Horner s method of polynomial evaluation and then divides the numerator response by the denominator response abs angle fft filter freqs i mpz invfreqz logspace Absolute value magnitude Phase angle One dimensional fast Fourier transform Filter data with a recursive IIR or nonrecursive FIR filter Frequency response of analog filters Impulse response of digital filters Discrete time filter identification from frequency data Generate logarithmically spaced vectors see the online MATLAB Function Reference gauspuls Purpose Syntax Description Remarks Gaussian modulated sinusoidal pulse generator yi gauspuls t fc bw yi gauspuls t fc bw bwr yi yg gauspuls yi yq ye gauspul s tc gauspuls cutoff fc bw bwr t pe
29. 256 2000 Q O Le i o o T 1 NO Q e T i W Q e T fi Magnitude Response dB A 3 fo L L L L L L L L 100 200 300 400 500 600 700 800 900 1000 Frequency Hertz 200f 4 400 J 600 Phase degrees 800 J sT 000 ji L i 1 ji 1 1 0 100 200 300 400 500 600 700 800 900 1000 Frequency Hertz 1 25 1 Signal Processing Basics 1 26 f reqz can also accept a vector of arbitrary frequency points for usein the frequency response calculation For example w linspace 0 pi h freqz b a w calculates the complex frequency response at the frequency points in w for the filter defined by vectors b anda The frequency points can range from 0 to 27 Tospecify a frequency vector that ranges from zeroto your sampling frequency include both the frequency vector and the sampling frequency value in the parameter list Analog Domain f reqs evaluates frequency response for an analog filter defined by two input coefficient vectors b anda Its operation is similar to that of f r eqz you can specify a number of frequency points to use by default the function uses 200 supply a vector of arbitrary frequency points and plot the magnitude and phase response of the filter Magnitude and Phase MATLAB provides functions to extract magnitude and phase from a frequency response vector h The function abs returns the magnitude of the response angl
30. 4 5 6 is c conv a b C 4 13 28 27 18 Usedeconv todivideb back out q r deconv c a q 0 0 0 0 0 This function is an M file in the MATLAB environment that uses thef i ter primitive Deconvolution is the impulse response of an IIR filter conv Convolution and polynomial multiplication filter Filter data with a recursive IIR or nonrecursive FIR filter resi duez z transform partial fraction expansion 6 97 demod Purpose Syntax Description 6 98 Demodulation for communications simulation x demod y Fc Fs method x demod y Fc Fs method opt x demod y Fc Fs pwm centered x1 x2 demod y Fc Fs qam demod performs demodulation that is it obtains the original signal froma modulated version of the signal demod undoes the operation performed by modulate x demod y Fc Fs method opt demodulates the real carrier signal y with a carrier frequency Fc and sampling frequency Fs using one of the options listed below for met hod Note that some methods accept an option opt amdsb sc Amplitude demodulation double sideband suppressed carrier Multipliesy by a sinusoid of frequency Fc and applies a or fifth order Butterworth lowpass filter usingfiltfilt x y cos 2 pi Fc t am b a butter 5 Fc 2 Fs x filtfilt b a x amdsb tc Amplitude demodulation double sideband transmitted carrier Multipliesy by a sinusoid of frequency Fc and applies a f
31. Algorithm See Also References 6 116 Elliptic analog lowpass filter prototype z p k ellipap n Rp Rs z p k ellipap n Rp Rs returns the zeros poles and gain of an order n elliptic analog lowpass filter prototype with Rp dB of ripple in the passband anda stopbandRs dB down fromthe peak valuein the passband The zeros and poles are returned in length n column vectorsz and p and the gain in scalar k Ifn is odd z is length n 1 The transfer function is 2 5 _ 8 zs 22 s z P s s POs p Cs p n H s Elliptic filters are equiripplein both the passband and stopband They offer steeper rolloff characteristics than Butterworth and Chebyshev filters but they are equiripplein both the passband and the stopband Of the four classical filter types elliptic filters usually meet a given set of filter performance specifications with the lowest filter order ell ip sets the cutoff frequency g of the elliptic filter to 1 for a normalized result The cutoff frequency is the frequency at which the passband ends and the filter has a magnitude response of 10 RP 20 ell i pap uses the algorithm outlined in 1 It employs the M filee i pk to calculate the complete elliptic integral of the first kind and the M filee i pj to calculate J acobi elliptic functions besselap Bessel analog lowpass filter prototype buttap Butterworth analog lowpass filter prototype cheblap Chebyshev type analog lowpass filte
32. Biverbedde eee 5 76 Frequency Axis Settings 0c eee e eee eee 5 77 ZOOM CONTOS eee seek cee alee dw eae ee ca ce we 5 78 HEP BUCO gic are eai Pants Aik area ap a ah ges SAQA a aoe de 5 78 Main Plots Area enara Gata op ai ERa pees wees 5 78 Viewing Filter Plots 0 0 0 0 eee eee 5 80 Viewing Magnitude Response 0000e eee ee 5 80 Viewing Phase Response 0 00 cece eee eee 5 82 Viewing Group Delay 0 00 c eee eee ee 5 84 Viewing a Zero PolePlot 0c cee eee ee 5 85 Viewing Impulse Response 00002 e eee eee 5 85 Viewing Step Response 00 0 cece eee eee 5 87 viii Contents Using the Spectrum Viewer Interactive PSD Analysis 5 88 Opening the Spectrum Viewer 0 000 e eee eee 5 88 Basic Spectrum Viewer Functions 0 0 0005 5 89 MENUS apena ra Ge ae aa ae deka Grain dar day bans pa 5 90 Signal ID Panel 0 00 00 cece eee 5 90 Spectrum Management Buttons 20055 5 91 Zoom ControlS 0 eee 5 91 Ruler and Line Display Controls 5 91 Hap BUttOM sc santiaosed sarni anaa N Ra Aan ayes Gee ae 5 91 Main Axes Display Area 0 0c cece eee 5 92 Making Spectrum Measurements 0000e neues 5 92 Viewing Spectral Density Plots 0 000005 5 93 Controlling and Manipulating Plots 4 5 93 Changing Plot Properties 00 00 c eee eee 5 93 Choosin
33. Filter Pop Up Menu 0 cece 5 57 ZOOM CONTOS ose eecpe ed Sa Same ed eee 5 57 Help Button iiia tipsa ck eee es a hed Bee eee bee 5 57 General Controls 0 0000 eee ees 5 58 Filter Specifications Panel 000 c eee eee 5 59 Filter Measurements Panel 000 eee eeee 5 61 Magnitude Plot Display Area 0 000005 5 62 Specification LineS 1 2 assas asana ee 5 62 Measurement LineS 0 0 0 cece eee eee 5 62 Designing Finite Impulse Response FIR Filters 5 63 Example FIR Filter Design Standard Band Configuration 5 63 Filter Design Options 0 00 e eee eee 5 65 Order Selection for FIR Filter Design 5 65 Designing Infinite Impulse Response IIR Filters 5 66 Example Classical IIR Filter Design 5 66 Filter Design Options 0 00 e eee eee 5 67 Order Selection for IIR Filter Design 5 68 Redesigning a Filter Using the Magnitude Plot 5 68 Saving Filter Data 0 cee 5 69 Viewing Frequency Response Plots 2 0005 5 73 Using the Filter Viewer Interactive Filter Analysis 5 74 Opening the Filter Viewer 0 000 c eee eee ee 5 74 Basic Filter Viewer Functions 0000e eee eeee 5 75 MEDUS ie aha Sib nan Sohal Rig wt eae ay tik tre aah de EERE 5 76 Filter Identification Panel 000 e eee eee 5 76 Plots Panel io erie 208s arira bbe vehi
34. Fs is a scalar that specifies the sampling frequency wi ndow specifies a windowing function and the number of samples cs d uses in its sectioning of thex andy vectors noverlap is the number of samples by which the sections overlap Any arguments omitted from the end of the parameter list use the default values shown above Ifx andy arereal csd estimates the cross spectral density at positive frequencies only in this case the output P xy is a column vector of length nf ft 2 1 fornfft evenand nfft 1 2 fornfft odd Ifx ory is complex csd estimates the cross spectral density at both positive and negative frequencies and Pxy has length nfft Pxy csd x y nfft usestheFFT lengthnfft in estimating the cross spectral density of x and y Specify nf ft as a power of 2 for fastest execution Pxy f csd x y nfft fs returns a vector f of frequencies at which the function evaluates theCSD f isthesamesizeasPxy Sopl ot f Pxy plots the csd spectrum versus properly scaled frequency fs has no effect on the output Px y it is a frequency scaling multiplier Pxy csd x y nfft Fs window specifies a windowing function and the number of samples per section of thex vector If you supply a scalar for wi ndow csd uses a Hanning window of that length The length of the window must be less than or equal tonf f t cs d zero pads the sections if the length of the window is less than nf ft csd returns an error if the length of the window is
35. If the length of x is greater thann f ft truncates the sequencex Ifx isan array f ft adjusts the length of the columns in the same manner fft is part of the standard MATLAB environment A common use of the F ourier transform is to find the frequency components of a time domain signal buried in noise Consider data sampled at 1000 Hz Form a signal consisting of 50 Hz and 120 Hz sinusoids and corrupt the signal with zero mean random noise t 0 0 001 0 6 x sin 2 pi 50 t sin 2 pi 120 t y x 2 randn 1 length t plot y 1 50 4 r 3L 2L il ol J al i ah gh 4l 5l 5 10 15 20 25 90 35 49 45 50 It is difficult to identify the frequency components by studying the original signal Convert to the frequency domain by taking the discrete F ourier transform of the noisy signal y using a 512 point fast Fourier transform FFT Y fft y 512 The power spectral density a measurement of the energy at various frequencies is Pyy Y conj Y 512 6 123 Algorithm 6 124 Graph the first 256 points the other 256 points are symmetric on a meaningful frequency axis f 1000 0 255 512 plot f Pyy 1 256 80 70 J 60F 4 50F 4 40 J 307 4 20 4 10 1 Wt n L L 0 50 100 150 200 250 300 350 400 450 500 See the psd function for details on calculating spectral density Sometimes it is useful t
36. M Lang and C S Burrus Constrained Least Square Design of FIR Filters without Specified Transition Bands Proceedings of the IEEE Int Conf Acoust Speech Signal Processing Vol 2 May 1995 Pgs 1260 1263 2 Selesnick W M Lang and C S Burrus Constrained Least Square Design of FIR Filters without Specified Transition Bands IEEE Transactions on Signal Processing Vol 44 No 8 August 1996 6 149 firls Purpose Syntax Description 6 150 Least square linear phase FIR filter design firls n firls n firls n firls n f a w ftype ano ot firls designs a linear phase FIR filter that minimizes the weighted integrated squared error between an ideal piecewise linear function and the magnitude response of the filter over a set of desired frequency bands b firls n f a returns row vector b containing then 1 coefficients of the order n FIR filter whose frequency amplitude characteristics approximately match those given by vectorsf anda The output filter coefficients or taps in b obey the symmetry relation b k b n 2 k k 1 2 1 These are type n odd and typell n even linear phase filters Vectorsf and a specify the frequency amplitude characteristics of the filter e f isavector of pairs of frequency points specified in the range between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Thefrequencies must bein increasing
37. PP ff pyulear xx 4 512 The Yule Walker AR estimate is given by the formula 1 Po fj nS la eco where the vector of all pole filter coefficients a is the solution of the autocorrelation normal equation Ra r The matrix R is the autocorrelation matrix which should be Toeplitz 1 The elements of the vector r are also correlations There must be at least one output argument and at least two inputs otherwise pyul ear stops and generates one of the following error messages Must have at least 1 output argument Must have at least 2 input arguments The first argument must be a full matrix otherwise pyul ear generates the following error message Input signal or correlation cannot be sparse pyulear If you specify an empty matrix for the second argument py ul ear generates the following error message Model be given empty not allowed If the final argument isthestring corr then the first input must bea square correlation matrix that is also Hermitian symmetric otherwise pyul ear gives the following error messages Correlation matrix R is not square Correlation matrix R is not Hermitian symmetric See Also Ipc Linear prediction coefficients pburg Power spectrum estimate using the Burg method pmt m Power spectrum estimate using the multitaper method MTM pmusic Power spectrum estimate using MUSIC eigenvector method prony Prony s method for time domain IHR filter design ps
38. Purpose Syntax Description Example Recursive digital filter design b a yulewal k n f m yul ewal k designs recursive IIR digital filters using a least squares fit toa specified frequency response b a yulewalk n f m returns row vectors b anda containing then 1 coefficients of the order n IIR filter whose frequency magnitude characteristics approximately match those given in vectorsf and m e f isa vector of frequency points specified in the range between 0 and 1 where 1 corresponds to half the sample frequency the Nyquist frequency The first point of f must be 0 and the last point 1 with all intermediate points in increasing order Duplicate frequency points are allowed corresponding to steps in the frequency response e mis a vector containing the desired magnitude response at the points specified in f e f and m must be the same length e plot f m displays the filter shape The output filter coefficients are ordered in descending powers of z B z _ B b 2 z 1 b Dz A z a 1 a 2 z7 te a n l z When specifying the frequency response avoid excessively sharp transitions from passband to stopband You may need to experiment with the slope of the transition region to get the best filter design Design an 8th order lowpass filter and overplot the desired frequency response with the actual frequency response f m 6 333 yulewalk Algorithm 6 334 b a yulewalk 8 f m
39. Since the signal xn is real psd returns only the frequencies from 0 through the Nyquist frequency In contrast the earlier FFT example generated PSD estimates ranging from 0 through the sampling frequency Bias and Normalization in Welch s Method In studying the output of psd shown earlier several revealing characteristics about the signal xn are evident The noise floor is flat at O decibels dB implying white noise of variance 1 Furthermore the signal part of xn is concentrated in two peaks at 50 and 120 Hz The relation of the peak heights is meaningful For instance the 50 Hz peak is 6 dB below the 120 Hz peak verifying that the higher frequency sinusoid has twice the magnitude as the lower 10729 2 0 Unlike the relative heights the actual height of the peaks does not tell us much about the original amplitude of the sinusoids without some more analysis To obtain useful information about the peak amplitudes of the underlying sinusoids note that the expected value of the estimated PSD is T A 1 9 E P P W de O awe Ps Since the expected value is not equal to the true PSD the estimate is biased This quantity is the convolution of the true PSD with the squared magnitude of the window s discrete time F ourier transform W q scaled by the squared norm of the window The scaling factor is the sum of the squares of the window function Jol way This says that if P has
40. Syntax Description z transform partial fraction expansion r p k residuez b a b a residuez r p k residuez converts a discrete time system expressed as the ratio of two polynomials to partial fraction expansion or residue form It also converts the partial fraction expansion back to the original polynomial coefficients r p k residuez b a finds theresidues poles and direct terms of a partial fraction expansion of the ratio of two polynomials b z and a z Vectors b anda specify the coefficients of the polynomials of the discrete time system b z a z in descending powers of z b z by z b Bz a z ag az az te ayz If there are no multiple roots anda gt n 1 Oj cp foe O a z 1 1 1 1 I k k 2 27 e tk m nt hg 7 9 a p nyz The returned column vector r contains the residues column vector p contains the pole locations and row vector k contains the direct terms The number of poles is n length a 1 length r length p The direct term coefficient vector k is empty iflength b lt length a otherwise length k length b length a 1 Ifp j p j s 1 isa pole of multiplicity s then the expansion includes terms of the form rg a4 aes fe L pQ z dpe l p z 6 271 residuez Algorithm Diagnostics 6 272 b a residuez r p k with threeinput arguments and two output arguments converts the partial fraction expansion back
41. and analyze the frequency content of signals This chapter describes how to use the different components of SPTool Where appropriate we point you to other areas of the manual that describe how to perform similar tasks by calling functions from the command line or from M files The section Example Generation of Bandlimited Noise at the end of this chapter describes how to use this graphical environment for a complete filter design and analysis task Overview SPTool is a graphical environment for analyzing and manipulating digital signals filters and spectra It is the starting point for using the interactive signal processing environment In SPTool you can import signals filters and spectra either from the workspace or as MAT files Through SPTool you access four additional GUI tools that provide an integrated environment for signal browsing filter design analysis and implementation The four components of the interactive signal processing environment include e The Signal Browser which provides a graphical view of the signal objects currently selected in SPTool and enables you to interactively display measure and analyze these signals e The Filter Designer which enables you to create and edit lowpass highpass bandpass and bandstop FIR and IIR digital filters of various lengths and types using the filter design functions of the Signal Processing Toolbox e The Filter Viewer which enables you to view various characte
42. and the Peaks and or Valleys controls on the selected line The label of the selected signal line is displayed in the Selection pop up menu There are two ways to select a signal line e Click on the Selection pop up menu and drag to select the line to measure All signals that are currently selected in SPTool are listed Vector signals in the Signal Browser spectra in the Spectrum Viewer and filters in the F ilter Viewer are listed as single variables in the Signal Browser each column of a two dimensional signal matrix is listed as a separate variable e Movethe mouse pointer over any point in theline you want to select and click on it 5 33 5 Interactive Tools 5 34 The label of the signal including the column number if the line is one column of a matrix is displayed in the Selection pop up menu The line selection display changes to the color and pattern of the selected signal spectrum or filter Line Selection Pop Up Menu Use to Select a line vector signal array column filter or spectrum to measure Click the Selection pop up menu and drag to select the line Line Selection Display Thelinecolor and style of the selected signal are displayed Color Button Use to edit the line style or display color of the selected line Click on the Color button at the top right of the window to display the Edit Line pop up menu which is shown on the left The label of the selected line is displayed in t
43. and yp are indexed from 0 to N 1 and Ryy m from N 1 to N 1 Thexcorr function evaluates this sum with an efficient FFT based algorithm given inputs x and yp stored in length N vectors x andy Its operation is equivalent to convolution with one of the two subsequences reversed in time For example xo arr 2s y X xyc xcorr x y gt lt a iT PNM Ww FW Se WwW PP Pe ooCoOCO OOOO Go 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ooCoOCO OOOO O Notice that the resulting sequence is twice the length of the input sequence minus 1 Thus the Nth element is the correlation at lag 0 Also notice the triangular pulse of the output that results when convolving two square pulses Thexcov function estimates autocovariance and cross covariance sequences This function has the same options and evaluates the same sum asxcorr but first removes the means of x andy Bias and Normalization An estimate of a quantity is biased if its expected value is not equal to the quantity it estimates The expected value of the output of xcorr is N m 1 E R m L E X Vhem N gk ImM Yxy m n 0 3 3 3 Statistical Signal Processing 3 4 xcorr provides the unbiased estimate dividing by N m when you specify an unbiased flag after the input sequences xcorr x y unbiased Although this estimate is unbiased the end points near N 1 and N 1 suffer from large variance becausex cor r
44. chirp t f0 t1 f1 method specifies alternative sweep method options where met hod can be e i near which specifies an instantaneous frequency sweep f t given by Si fo Br where B fo t B ensures that the desired frequency breakpoint f at time t is maintained e quadratic which specifies an instantaneous frequency sweep f t given by fit fo Br where B fo t e logarithmic specifies an instantaneous frequency sweep f t given by filt fo 10 where B logio A fo t For a log sweep f 1 must be greater than f 0 6 61 y chirp t f0 t1 f1 method phi allows an initial phasephi tobe specified in degrees If unspecified phi is 0 Default values are substituted for empty or omitted trailing input arguments Examples Compute the spectrogram of a chirp with linear instantaneous frequency deviation t 0 0 001 2 2 secs 1kHz sample rate y chirp t 0 1 150 Start DC cross 150Hz at t 1 sec specgram y 256 1e3 256 250 Display the spectrogram 500 450 400 5 300 O E 2250 200 6 62 chirp Compute the spectrogram of a chirp with quadratic instantaneous frequency deviation t 2 0 001 2 y chirp t 100 1 200 quadratic Start 100Hz at t 1 sec Display the spectrogram 2 secs 1kHz sample rate cross 200Hz specgram y 128 1e3 128 120 Frequency chirp See Also 6 64 cos diric gauspuls pulstran rectpul
45. dragging to edit filter 5 62 specifications for filter design 2 7 spectral analysis 3 5 cross spectral density 3 13 defined 3 5 power spectral density 3 5 using Spectrum Viewer 5 88 Yule Walker AR method 4 11 spectral density 3 5 See also power spectral density cross spectral density spectral density plot in Spectrum Viewer 5 92 spectrogram 4 26 6 284 example 4 26 6 322 spectrum computing in SPTool 5 19 5 20 importing into SPTool 5 8 5 10 5 13 linking to signal 5 90 measurements 5 37 measurements in Spectrum Viewer 5 35 5 92 naming in SPTool 5 17 peaks 5 36 updating in SPTool 5 20 valleys 5 36 viewing in Spectrum Viewer 5 88 viewing in SPTool 5 20 spectrum type auto 5 15 Spectrum Viewer 5 3 5 19 5 88 6 292 activating 5 19 5 88 changing plot properties 5 93 customizing 5 21 default plot 5 93 setting confidence intervals 5 98 viewing power spectral density plots 5 93 window 5 89 speech processing 4 10 4 21 spline 4 22 spt extension 5 7 SPTool 5 2 6 289 activating from Signal Browser 5 53 closing 5 7 customizing 5 7 5 21 loading 5 4 preferences 5 7 window 5 6 sptool command 6 10 6 289 square 1 8 6 2 6 293 square wave 1 8 ss2sos 1 42 6 4 6 294 ss2tf 6 297 ss2tf 1 42 6 297 ss2zp 1 42 6 4 6 298 stabilization polynomial 6 236 standards Compact Disc 4 20 Digital Audio Tape 4 20 startup transients 1 22 reducing 1 21 6 134 state space form 1 40 1 42 converting to second order section 6 294 conver
46. e up to order the sections so the first row of sos contains the poles farthest from the unit circle default Find a second order section form of a Butterworth lowpass filter z p k butter 5 0 2 sos zp2s0s z p k zp2sos uses a four step algorithm to determine the second order section representation for an input zero pole gain system 1 It groups the zeros and poles into complex conjugate pairs using the cpl xpair function 2 It forms the second order section by matching the pole and zero pairs according to the following rules a Match the poles closest to the unit circle with the zeros closest to those poles b Match the poles next closest to the unit circle with the zeros closest to those poles c Continue until all of the poles and zeros are matched zp2s0s groups real poles into sections with the real poles closest to them in absolute value The same rule holds for real zeros 3 It orders the sections according to the proximity of the pole pairs to the unit circle zp2sos normally orders the sections with poles closest to the unit circle last in the cascade You can tell zp2so0s to order the sections in the reverse order by specifying the down flag Putting high Q sections at the beginning of the cascade by specifying the down flag reduces the response sensitivity of the filter to quantization noise near those poles Putting high Q sections at the end of the cascade the default prevents reduction i
47. followed by the zero pole gain form The transfer function form is the least accurate numerical problems can arise for filter orders as low as 15 6 114 ellip Algorithm See Also The design of elliptic filters is the most difficult and computationally intensive of the Butterworth Chebyshev type and I1 and elliptic designs el i p uses a five step algorithm 1 It finds the lowpass analog prototype poles zeros and gain using the ell i pap function 2 It converts the poles zeros and gain into state space form 3 It transforms the lowpass filter to a bandpass highpass or bandstop filter with the desired cutoff frequencies using a state space transformation For digital filter design el i p uses bilinear to convert the analog filter into a digital filter 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 or w1 and w2 It converts the state space filter back to transfer function or zero pole gain form as required bessel f Bessel analog filter design butter Butterworth analog and digital filter design chebyl Chebyshev type filter design passband ripple cheby2 Chebyshev type II filter design stopband ripple ellipap Elliptic analog lowpass filter prototype ellipord Elliptic filter order selection 6 115 ellipap Purpose Syntax Description
48. numbers are real and which are paired complex conjugates By default cpl xpair uses a tolerance of 100 eps relativetoabs x i cplxpair forces the complex conjugate pairs to be exact complex conjugates This function is part of the standard MATLAB environment Order five poles evenly spaced around the unit circle into complex pairs cpl xpair exp 2 pi sqrt 1 0 4 5 ans 0 8090 0 58781 0 8090 0 5878i 0 3090 0 95111 0 3090 0 95111 1 0000 If there is an odd number of complex numbers or if the complex numbers cannot be grouped into complex conjugate pairs within thetolerance cp xpai r generates the error message Complex numbers can t be paired cremez Purpose Syntax Description Complex and nonlinear phase equiripple FIR filter design b cremez n f fresp b cremez n f fresp w b cremez n f fresp pl p2 w b cremez n f a w b cremez sym b cremez skip_stage2 b cremez debug b cremez lgrid b delta opt cremez cremez allows arbitrary frequency domain constraints to be specified for the design of a possibly complex FIR filter The Chebyshev or minimax filter error is optimized producing equiripple FIR filter designs b cremez n f fresp returns a length n 1 FIR filter with the best approximation to the desired frequency response as returned by function fresp f iS a vector of frequency band edge pairs specified
49. plots vector x in strips that are each n samples long x sd Fs plots vector x in strips of duration sd seconds given a sampling frequency of Fs samples per second stri ps x sd Fs scale scales the vertical axes Ifx isamatrix strips x n strips x sd Fs andstrips x sd Fs scale plot the different columns of x on the same strip plot strips ignores the imaginary part of x if it is complex strips Example Plot two seconds of a frequency modulated sinusoid in 0 25 second strips Fs 1000 sampling frequency t O 1 Fs 2 time vector x vco sin 2 pi t 10 490 Fs FM waveform strips x 0 25 Fs 0 0 05 0 1 0 15 0 2 0 25 See Also plot Linear two dimensional plot seethe online MATLAB Function Reference stem Plot discrete sequence data see the online MATLAB Function Reference 6 305 tf2latc Purpose Syntax Description See Also 6 306 Transfer function to lattice filter conversion k v tf2latc num den k tf2latc 1 den k v tf2latc 1 den k tf2latc num k v tf2latc num den finds the lattice parameters k and the ladder parameters v for an IIR ARMA lattice ladder filter normalized by den 1 Note that an error will be generated if any poles of the transfer function lie on the unit circle k tf2latc 1 den finds the lattice parameters k for an IIR all pole AR lattice filter k v tf2latc 1 den returns a scalar ladder coeff
50. s operator H ere A w k and B w k are the Fourier transforms of the polynomials a andb respectively at the frequency w k and n is the number of frequency points the length ofh and w This algorithm is a based on Levi 1 The superior output error algorithm uses the damped Gauss N ewton method for iterative search 2 with the output of the first algorithm as the initial estimate This solves the direct problem of minimizing the weighted sum of the squared error between the actual and the desired frequency response points 2 B w k min t kyh k 2 L AWE freqs Frequency response of analog filters freqz Frequency response of digital filters invfreqs Continuous time analog filter identification from frequency data prony Prony s method for time domain IHR filter design 1 Levi E C Complex Curve Fitting IRE Trans on Automatic Control Vol AC 4 1959 Pgs 37 44 2 Dennis J E r and R B Schnabel Numerical Methods for Unconstrained Optimization and Nonlinear Equations Englewood Cliffs NJ Prentice Hall 1983 kaiser Purpose Syntax Description See Also References Kaiser window w kaiser n beta w kaiser n beta returns ann point Kaiser l sinh window in the column vector w beta isthe Kaiser window B parameter that affects the sidelobe attenuation of the Fourier transform of the window To obtain a Kaiser window that designs an FIR filt
51. s to design an interpolation FIR equivalent to that presented in 1 The polynomial method uses Lagrange s polynomial interpolation formula on equally spaced samples to construct the appropriate filter deci mate Decrease the sampling rate for a sequence decimation interp Increase sampling rate by an integer factor interpolation resample Change sampling rate by any factor 1 Oetken Parks and Sch ler New Results in the Design of Digital Interpolators IEEE Trans Acoust Speech Signal Processing Vol ASSP 23 J une 1975 Pgs 301 309 6 185 invfreqs Purpose Syntax Description 6 186 Continuous time analog filter identification from frequency data b a invfregs h w nb na b a invfregs h w nb na wt b a invfregs h w nb na wt iter b a invfregs h w nb na wt iter tol b a invfregs h w nb na wt iter tol trace b a invfregs h w complex nb na i nvf reqs is theinverse operation off reqs it finds a continuous time transfer function that corresponds to a given complex frequency response From a laboratory analysis standpoint i nvf reqs is useful in converting magnitude and phase data into transfer functions b a invfreqs h w nb na returns the real numerator and denominator coefficient vectors b anda of the transfer function B s _ b I s 2 b nb 1 a A s a 1 s ao FaF a na 1 whose complex frequency response
52. signal e A rectangular possibly square array assumes that each column of x isa separate observation of the process output for example each column is one output of an array of sensors as in array processing e A square matrix given thetrailing argument corr represents a correlation matrix The second argument is a one or two element vector either p or p thresh If only p is specified the signal subspace dimension isp If p thresh is specified thr esh is multiplied by Amin the smallest eigenvalue eigenvalues below the threshold Amin thr esh are assigned to the noise subspace In this case p is the maximum dimension of the signal subspace pmusic Remarks CAUTION pmusi c must assign eigenvectors to the noise and signal subspaces but this is very difficult to doin practice The two parameters p andt hresh are provided for flexibility and control Pxx f pmusic x p thresh nfft Fs window noverlap Specifies the FFT length nf ft default is 256 and the sampling frequency for the signal Fs default is 2 If Fs is specified the output frequency vector f is scaled by this value If the input signal is real valued the frequency range is 0 toFs 2 for the complex case it is OtoFs wi ndow is a Scalar specifying the rectangular window length or a vector giving the actual window coefficients noverlap used in conjunction with wi ndow is a scalar that gives the number of points by which to overlap successiv
53. sos2tf uses theconv function to multiply all of the numerator and denominator second order polynomials together sos2tf Example Compute the transfer function representation of a simple second order section form system sos 1 1 1 1 0 1 2 3 1 110 1 b a sos2tf sos b 2 1 2 4 1 a 1 10 0 10 1 See Also 0S255S Second order section to state space conversion 0S 2zp Second order section to zero pole gain conversion 552505 State space to second order section conversion zp2so0s Zero pole gain to second order section conversion 6 281 sos2zp Purpose Syntax Description 6 282 Second order section to zero pole gain conversion z p k so0s2zp sos sos2zp converts a second order section representation of a given system to an equivalent zero pole gain representation z p k sos2zp sos returnsthezerosz polesp and gain k of the system given by sos in second order section form The second order section format of H z is given by bo b lip 2 l l Z vd A z H z Ok lk I 2k 7 k 1 A0k T Ak akz k 1 where L is the number of rows of sos sos is an L by 6 matrix which contains the coefficients of each second order section stored in its rows boy b bza a9 a ay bo2 bi2 bn ap ap an SOSE bon Sin bL aoL AL aL Column vectors z andp contain the zeros and poles of the transfer function H z k z 2 DXz z 2 z z N p p p p 2 p p M where the
54. the filter design and resampling are separate steps Note that resample would do both steps as one upf i rdn uses a polyphase interpolation structure The number of multiply add operations in the polyphase structure is approximately L L pL q where Lp and L are the lengths of h n and x n respectively A more accurate flops count is computed in the program but the actual count is still approximate For long signals x n the formula is quite often exact There must be one output argument and at least twoinput arguments If either of these conditions are violated upf i rdn gives the appropriate error message UPFI RDN needs at least two input arguments UPFIRDN should have exactly one output argument If the arrays are sparse upf i rdn gives the error message H must be full numeric matrix When the input signals are in the columns of a matrix and there are multiple filters also in the columns of a matrix the number of signals and filters must be the same If they are not upf i rdn gives the error message X and H must have the same number of columns if more than one The arguments p and q must be integers If they are not upf i rdn gives the error message P and or Q must be greater than zero If the arguments p and q are not relatively prime upf i r dn gives the warning message WARNING upfirdn p amp q have common factor upfirdn See Also References conv deci mate filter interp intfilt
55. upfirdn VCO Increase sampling rate by an integer factor interpolation One dimensional median filtering Modulation for communications simulation Stabilize polynomial Real cepstrum and minimum phase reconstruction Change sampling rate by any factor Time dependent frequency analysis spectrogram Upsample apply an FIR filter and downsample Voltage controlled oscillator Analog Prototype Design bessel ap buttap cheblap cheb2ap ellipap Bessel analog lowpass filter prototype Butterworth analog lowpass filter prototype Chebyshev type analog lowpass filter prototype Chebyshev type II analog lowpass filter prototype Elliptic analog lowpass filter prototype 6 9 6 Reference 6 10 Frequency Translation p2bp p2bs p2hp lp2lp Lowpass to bandpass analog filter transformation Lowpass to bandstop analog filter transformation Lowpass to highpass analog filter transformation Lowpass to lowpass analog filter transformation Filter Discretization bilinear i mpi nvar Map variables using bilinear transformation Impulse invariance method of analog to digital filter conversion Interactive Tools sptool Interactive digital signal processing tool SPTool abs Purpose Syntax Description Example See Also Absolute value magnitude y abs x y abs x returns theabsolute value of the elements of x Ix is complex abs retur
56. where N is the dimension of the eigenvectors and v is the k th eigenvector of thecorrelation matrix of theinput signal The integer p is the dimension of the signal subspace so the eigenvectors v used in the sum correspond to the smallest eigenvalues and also span the noise subspace The vector e f consists of complex exponentials so the inner product vel f amounts to a Fourier transform The second form is preferred for computation because the FFT is computed for each v and then the squared magnitudes are summed In the eigenvector method the summation is weighted by the eigenvalues i of the correlation matrix eG ya en Ak k p 1 The function relies on thesvd matrix decomposition in the signal case and it uses theei g function for analyzing the correlation matrix If SVD is used the correlation matrix is never explicitly computed but the singular values are the k There must be at least one output argument and at least two inputs otherwise pmusi c stops and gives one of the following error messages Must have at least 1 output argument Must have at least 2 input arguments The first argument must bea full matrix otherwisepmusi c gives the following error message Input signal or correlation cannot be sparse pmusic See Also References If the second argument was entered as an empty matrix or if it has more than two elements or if it has negative or non integer elements p mus i c gives one o
57. which has a desired amplitude of 1 across the entire band e differentiator for typelll and type IV filters using a special weighting technique For nonzero amplitude bands the integrated squared error has a weight of 1 f 2 so that the error at low frequencies is much smaller than at high frequencies For FIR differentiators which havean amplitude characteristic proportional to frequency the filters minimize the relative integrated squared error the integral of the square of the ratio of the error to the desired amplitude 6 151 firls Examples Algorithm 6 152 Design an order 255 lowpass filter with transition band b firls 255 0 0 25 0 3 1 1 1 0 0 Design a 31 coefficient differentiator b firls 30 0 0 9 0 0 9 differentiator Design a 24th order anti symmetric filter with piecewise linear passbands and plot the desired and actual frequency response F 00 3 0 4 0 6 0 7 0 9 Az 0 1 0 0 0 5 0 5 b firls 24 F A hilbert for i 1 2 6 plot F i F i 1 A i A i 1 freqz b 1 512 2 f abs H grid on hold off Reference 1 describes the theoretical approach that f i r hold on s takes Thefunction solves a system of linear equations involving an inner product matrix of size roughly n 2 using MATLAB s operator firls This function designs typeI II III and IV linear phase filters Type and II are the defaults for n even and odd resp
58. x m z m 1 a ym zy b 2 x m z2 m 1 a 2 y m Zn 2 m b n 1I x m Z _ 1 m 1 a n Dy m Zy 1 m b n x m a n ym You can usef i tic to generate the state vector z 0 from past inputs and outputs The input output description of this filtering operation in the z transform domain is a rational transfer function BOB b nb 1 a l a 2 z 1 a nat Ng Y z X z If a 1 0 filter gives the following error message First denominator coefficient must be nonzero If the length of the initial condition vector is not the greater of na and nb filter gives the following error message Initial condition vector has incorrect dimensions fftfilt FFT based FIR filtering using the overlap add method filter2 Two dimensional digital filtering filtfilt Zero phase digital filtering filtic Make initial conditions for fi ter function 1 Oppenheim A V and R W Schafer Discr amp ee Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 311 312 filter2 Purpose Syntax Description Algorithm See Also Two dimensional digital filtering Y filter2 B X Y filter2 B X shape y filter2 B X filters the two dimensional data in X with the two dimensional FIR filter in the matrix B The result Y is computed using two dimensional convolution and is the same size as x Y filter2 B X shape returnsY computed with
59. ym rceps x wherey is thereal cepstrum and y m is the minimum phase reconstruction of x Inverse Complex Cepstrum Toinvert the complex cepstrum use thei cceps function Inversion is complicated by the fact that thecceps function performs a data dependent phase modification so that the unwrapped phase of its input is continuous at zero frequency The phase modification is equivalent to an integer delay This delay term is returned bycceps if you ask for a second output For example x 1 10 xh nd cceps x xh Columns 1 through 7 2 2428 0 0420 0 0210 0 0045 0 0366 0 0788 0 1386 Columns 8 through 10 0 2327 0 4114 0 9249 nd 1 Toinvert the complex cepstrum usei cceps with the original delay parameter icceps xh nd ans Columns 1 through 7 1 0000 2 0000 3 0000 4 0000 5 0000 6 0000 7 0000 Columns 8 through 10 8 0000 9 0000 10 0000 NOTE With any modification of the complex cepstrum the original delay term may no longer be valid Use thei cceps function with care 4 25 4 Special Topics FFT Based Time Frequency Analysis The Signal Processing Toolbox provides a function s pecgram that returns the time dependent Fourier transform for a sequence or displays this information as a spectrogram The time dependent Fourier transform is the discrete time Fourier transform for a sequence computed using a sliding window This form of the Fourier transform also known as the short time F ourier transfo
60. z tom by aan 2 2fs bilinear can accept an optional parameter F p that specifies prewarping Fp in Hertz indicates a match frequency that is a frequency for which the frequency responses before and after mapping match exactly In prewarped mode the bilinear transformation maps the s plane into the z plane with H z H s __ 2 GD tan 272 1 With the prewarping option bi i near maps the jQ axis from Q to repeatedly around the unit circle exp jw from r to m by J i Q anz P 2mfp 2tan bilinear In prewarped mode bi i near matches the frequency 2zf in radians per second in the s plane to the normalized frequency 2zf f in radians per second in the z plane Thebi linear function works with three different linear system representations zero pole gain transfer function and state space form Zero Pole Gain zd pd kd bilinear z p k Fs and zd pd kd bilinear z p k Fs Fp convert the s domain transfer function specified by z p and k toa discrete equivalent nputsz andp are column vectors containing the zeros and poles and k is a scalar gain Fs isthe sampling frequency in Hertz bili near returns the discrete equivalent in column vectorszd andpd and scalar kd Fp is the optional match frequency in Hertz for prewarping Transfer Function numd dend bilinear num den Fs and numd dend bilinear num den Fs Fp convert an s domain transfer
61. zero on both edges 1 21 1 Signal Processing Basics 1 22 Frequency Domain Filter Implementation Duality between the time domain and the frequency domain makes it possible to perform any operation in either domain Usually one domain or the other is more convenient for a particular operation but you can always accomplish a given operation in either domain To implement general IIR filtering in the frequency domain multiply the discrete F ourier transform DFT of theinput sequence with the quotient of the DFT of the filter n length x y ifft fft x fft b n fft a n This computes results that are identical tof i ter but with different startup transients edge effects For long sequences this computation is very inefficient because of the large zero padded FFT operations on the filter coefficients and because the FFT algorithm becomes less efficient as the number of points n increases For FIR filters however it is possible to break longer sequences into shorter computationally efficient FFT lengths The function y fftfilt b x uses the overlap add method see reference 1 at the end of this chapter to filter a long sequence with multiple medium length FFTs Its output is equivalent tofilter b 1 x Impulse Response Impulse Response The impulse response of a digital filter is the output arising from the input sequence Gi l n 1 EMAL 0 n l1 In MATLAB you can generate an impulse se
62. 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Weighted CLS Filter Design Weighted CLS filter design lets you design lowpass or highpass FIR filters with relative weighting of the error minimization in each band Thefircls1 function enables you to specify the passband and stopband edges for the least squares weighting function as well as a constant k that specifies the ratio of the stopband to passband weighting For example consider specifications that call for an FIR filter with impulse response order of 55 and cutoff frequency of 0 3 normalized Also assume FIR Filter Design maximum allowable passband ripple of 0 02 and maximum allowable stopband ripple of 0 004 In addition add weighting requirements e Passband edge for the weight function of 0 28 normalized e Stopband edge for the weight function of 0 32 e Weight error minimization 10 times as much in the stopband as in the passband To approach this usingfircls1 n 55 wo 0 3 dp 0 02 ds 0 004 wp 0 28 ws 0 32 k 10 h firclsl n wo dp ds wp ws k plot 0 2 Arbitrary Response Filter Design Thecr emez filter design function provides a tool for designing FIR filters with arbitrary complex responses It differs from the other filter design functions in how the frequency response of the filter is specified it accepts the name of a function which returns thefilter response calculated over a grid of frequencies 2 31 2 Filte
63. 0 255 256 Fs 10 10g10 Pxx Averaged Periodogram no overlap 25 T T T T T Power Spectrum dB 5F r L L L L L L L L L 0 100 200 300 400 500 600 700 800 900 1000 Frequency Hz This averaged estimate has one third the variance of the length 256 periodogram shown earlier The more sections you average the lower the variance of theresult H owever the signal length limits the number of sections possible to three sections of length 256 in the previous example To obtain more sections break the signal into overlapping sections Pxx abs fft xn 1 256 2 abs fft xn 129 384 2 abs fft xn 257 512 2 abs fft xn 385 640 2 abs fft xn 513 768 2 abs fft xn 641 896 2 256 6 plot 0 255 256 Fs 10 10g10 Pxx Averaged Periodogram 128 sample overlap Power Spectrum dB i i i i i i 0 100 200 300 400 500 600 700 800 900 1000 Frequency Hz 3 8 Spectral Analysis In this case the sections are statistically dependent resulting in higher variance thus there is a trade off between the number of sections and the overlap rate Another way toimprovethe periodogram estimateis to apply a nonrectangular data window to the sections prior to computing the periodogram resulting ina modified periodogram This reduces the effect of section dependence due to overlap because the window is tapered to 0 on the edges Also a nonrectangular window di
64. 0 55 1 lowpass 16 FIR Filter Design The resulting magnitude response is h w fregz b 1 512 whole plot w pi 1 fftshift abs h 1 4 T 1 PIN td T fi E D T f Magnitude Response o P T 1 0 ii L 1 0 8 0 6 0 4 0 4 0 6 0 8 1 0 2 0 Normalized Frequency The group delay of the filter reveals that the offset has been reduced from N 2 30 5 toN 2 16 14 5 Now however the group delay is no longer flat in the passband region plotted over the normalized frequency range 0 to 0 5 for clarity A a D T T T Group delay in samples wo T f 1 i f f f f f f 0 0 05 0 1 0 15 0 2 0 25 0 3 0 35 0 4 0 45 0 5 Normalized frequency Nyquist 1 2 35 2 Filter Design If we compare this nonlinear phase filter to a linear phase filter that has exactly 14 5 samples of group delay the resulting filter is of order 2 14 5 or 29 Usingb cremez 29 0 0 5 0 55 1 lowpass the passband and stopband rippleis much greater for the order 29 filter These comparisons can assist you in deciding which filter is more appropriate for a specific application 2 36 Special Topics in IIR Filter Design Special Topics in IIR Filter Design TheclassiclIR filter design technique finds an analog lowpass filter with cutoff frequency of 1 translates this prototype filter to the desired band configuration then transforms the filter to the digital doma
65. 0000 0 2402 The third input to maxflat is the half power frequency a frequency between 0 and 1 with a desired magnitude response of 1 2 You can also design linear phase filters that have the maximally flat property using the sym option maxflat 4 sym 0 3 ans 0 0331 0 2500 0 4337 0 2500 0 0331 For complete details of the maxf at algorithm see Selesnick and Burrus 2 2 15 2 Filter Design FIR Filter Design 2 16 Digital filters with finite duration impulse response all zero or FIR filters have both advantages and disadvantages compared to infinite duration impulse response IIR filters FIR filters have the following primary advantages e They can have exactly linear phase e They are always stable e The design methods are generally linear e They can be realized efficiently in hardware e The filter startup transients have finite duration The primary disadvantage of FIR filters is that they often require a much higher filter order than IIR filters to achieve a given level of performance FIR Filter Design Correspondingly the delay of these filters is often much greater than for an equal performance IIR filter Method Description Functions Windowing Apply window to truncated firl fir2 kaiserord inverse Fourier transform of desired brickwall filter Multiband Equiripple or least squares firls remez remezord with approach over sub bands of the Transition frequency range
66. 03731609173676 0 03731609173676 0 08249198453223 0 08249198453223 0 04583930972315 0 04583930972315 0 14255125351637 0 02829072973977 0 20400424807471 0 01433198229497 0 02685697779814 0 01148698991026 0 18956307836948 0 02266475846451 0 02717716288172 0 00206242734272 0 08057060786906 0 00545783754743 Notice that the first four samples match exactly For an example of exact recovery recover the coefficients of a Butterworth filter from its impulse response b a butter 4 2 h i mpz b a 26 bb aa prony h 4 4 Try this example you ll see that bb andaa match theoriginal filter coefficients to within a tolerance of 10 Steiglitz McBride Method ARMA Modeling st mc b determines the coefficients for the system b z a z given an approximate impulse response x as well as the desired number of zeros and poles This function identifies an unknown system based on both input and output 4 14 Parametric M odeling sequences that describe the system s behavior or just the impulse response of the system In its default mode st meb works like pr ony b a stmcb x 3 3 b 1 1165 0 6213 0 8365 1 3331 1 0000 0 5401 0 6109 1 1298 st mcb also finds systems that match given input and output sequences y filter 1 1 1 x Create an output signal b a stmcb y x 0 1 b 1 1 In this example st mcb correctly identifies the system used to createy from x The Steiglitz M
67. 1 21 example 1 20 initial conditions 1 21 filtic 1 18 6 3 6135 FIR filter arbitrary frequency response 6 141 compared to IIR 2 16 design 2 16 decimation 6 184 interpolation 6 184 least squares method 6 150 linear phase 6 150 multiband frequency response 6 141 Parks McClellan method 6 255 window method 6 137 differentiator 2 26 6 151 6 257 Hilbert transformer 2 25 6 151 6 257 implementation 1 17 6 130 FF T based 1 22 6 127 overlap add method 1 22 6 127 linear phase 2 17 6 255 order estimation remez function 6 263 types 6 153 6 260 FIR filter design 2 17 anti symmetric 2 25 arbitrary responses 2 31 complex filters 2 17 6 77 nonlinear phase 2 17 6 77 reduced delay 2 34 constrained least squares 2 17 2 27 linear phase 2 28 multiband 2 28 2 29 weighted 2 30 equiripple 2 17 2 22 2 23 5 63 5 65 example 5 63 5 100 in Filter Designer 5 55 5 63 Kaiser window 5 63 5 65 least squares 2 17 2 22 2 23 5 63 5 65 least squares compared to equiripple 2 23 linear phase filters 2 17 2 22 multiband 2 17 2 21 2 22 order selection 5 65 parameters in Filter Designer 5 65 Parks McClellan method 2 22 raised cosine method 2 17 role of Kaiser window 4 7 standard band 2 20 windowing method 2 17 2 18 FIR filtering in frequency domain 1 19 FIR lattice filter implementation 1 38 f ir 1 2 17 2 20 6 5 6 137 accessing from Filter Designer 5 63 5 65 fir2 2 17 2 20 6 5 6 141 example 2 21 fircls 2 17 6 5 6144 fircl
68. 1 3 creating xii 1 3 modifying xii viewing xii minima local 5 36 minimax method FIR filter design 2 22 See also Parks McClellan method minimum phase filter 6 236 models system representation 1 32 modified periodogram 3 9 modulate 4 28 6 9 6 218 example 4 30 method flags 4 29 modulation 6 218 amplitude defined 4 28 example 4 30 frequency methods 4 29 6 218 phase 4 29 pulse time 4 29 pulse width 4 29 quadrature amplitude 4 29 mouse zoom 5 31 in Filter Designer 5 21 in Filter Viewer 5 21 5 79 in Signal Browser 5 21 in Spectrum Viewer 5 21 turning off 5 32 Mouse Zoom button 5 31 moving average MA filter 1 15 See also FIR filter MTM Seemultitaper method multiband filter FIR 2 21 FIR with transition bands 2 22 IIR 2 13 multichannel data 1 4 1 7 multichannel signal 3 4 multiple signal classification method MUSIC 3 5 3 6 3 22 defined 3 22 in Spectrum Viewer 5 96 multirate filter bank implementation 1 19 multirate filtering 1 19 multitaper method MTM 3 5 3 6 3 16 compared to Welch s method 3 19 defined 3 16 example 3 17 in Spectrum Viewer 5 95 MUSIC Seemultiple signal classification method N New Design button 5 7 5 18 5 56 noninteger delay 2 26 nonrecursive filter See FIR filter 1 17 Index 1 18 normalization 3 3 correlation 3 4 6 325 power spectral density 3 11 Nyquist frequency xvii 2 2 0 objects editing in SPTool 5 16 one time mouse zooming 5 31 Open Session menu ite
69. 35 ruler type in Signal Browser 5 22 in Spectrum Viewer 5 22 rulers bringing to center 5 34 customizing in SPTool 5 21 dragging 5 35 find ruler buttons 5 34 horizontal 5 35 horizontal mode 5 39 in Filter Viewer 5 27 5 32 in Signal Browser 5 21 5 22 5 24 5 32 in Spectrum Viewer 5 21 5 22 5 25 5 32 parameters 5 36 positioning 5 37 preferences 5 22 saving measurements 5 36 slope 5 35 slope mode 5 41 track 5 35 track mode 5 40 vertical 5 35 vertical mode 5 38 Rulers check box in Preferences dialog box 5 24 5 25 5 27 S sampling frequency changing in SPTool 5 11 in SPTool 5 17 Sampling Frequency edit box in mport dialog box 5 6 5 11 Sampling Frequency menu item 5 17 sampling rate changing by noninteger factor 4 20 6 267 changing for irregularly spaced data 4 22 changing with upfirdn 1 19 decreasing by integer factor 6 94 increasing by integer factor 6 182 Save Rulers button 5 36 Save Session menu item 5 7 saving changes in SPT ool 5 29 saving data from Filter Designer 5 53 5 69 5 98 saving settings in Filter Viewer 5 76 sawtooth 1 8 6 2 6 274 sawtooth wave 1 8 1 21 Index 1 22 scalar for state space form 1 34 representing gain 1 33 Scale pop up menu Filter Viewer 5 77 Search for Plug Ins at start up check box in Pref erences dialog box 5 29 second order sections 1 42 second order sections form 1 37 converting to state space 6 278 converting to transfer function 6 280 converting to zero
70. 4 4 Kaiser WINdOW 0 0 c cee es 4 4 Kaiser Windows in FIR Design 0000 eee 4 7 Chebyshev Window 000 naea 4 9 Parametric Modeling 0 0 e cece eee eee eee 4 10 Time Domain Based Modeling 0 00 eee eee 4 11 Linear Prediction AR Modeling 00e eee 4 11 Prony s Method ARMA Modeling 00000es 4 12 Steiglitz McBride Method ARMA Modeling 4 14 Frequency Domain Based Modeling 00000eee 4 16 Resampling 3503556 nnana de eee 4 20 Cepstrum Analysis 0 0 0 00 c cee ee 4 23 Inverse Complex CepstruM 00 cee 4 25 FFT Based Time Frequency Analysis 4 26 Median Filtering 00 cece cece 4 27 Communications Applications 4 28 Deconvolution 0 0 cece eee 4 32 Specialized Transforms 000 cece eee ee 4 33 Chifp Z TranSfOny ane ssica eee eed ee hed wh Same Se 4 33 Discrete Cosine Transform 00 cece eee ee 4 35 Hilbert Transform 0 0 ccc cece eee eee a 4 37 References 233 6533 ee ee ee Pes 4 39 Interactive Tools 5 SPTool An Interactive Signal Processing Environment 5 2 OVENVIOW eek ted sel a ENTES eae ae Pee a 5 2 Using SPTool 6s ccc as here eee are pea ieee 5 4 Opening SP POO isis srine pen eenzee shared peed oda 5 4 QUICK STORE oie oid de tend Raa eel Gd Gd Se Da 5 4
71. 450 500 Frequency Hertz oO 200 1 Hass usyicce 400 1 L 1 1 I L ii L il 0 50 100 150 200 250 300 350 400 450 500 Freauencv Hertz Algorithm cheb2ord uses the Chebyshev lowpass filter order prediction formula described in 1 The function performs its calculations in the analog domain for both analog and digital cases For the digital case it converts the frequency parameters to the s domain before the order and natural frequency estimation process then converts them back to the z domain 6 48 cheb2ord cheb2ord initially develops a lowpass filter prototype by transforming the stopband frequencies of the desired filter to 1 rad sec for low and highpass filters and to 1 and 1 rad sec for bandpass and bandstop filters It then computes the minimum order required for a lowpass filter to meet the passband specification See Also buttord Butterworth filter order selection cheblord Chebyshev type filter order selection cheby2 Chebyshev type filter design stopband ripple ellipord Elliptic filter order selection kaiserord Estimate parameters for an FIR filter design with Kaiser window References 1 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pg 241 chebwin Purpose Syntax Description See Also References 6 50 Chebyshev window w chebwin n r w chebwin n r returns the column vec
72. 5 0 0 5 1 Real part To generate the same plot with a transfer function representation of the filter b a butter 5 0 2 transfer function zpl ane b a See Also freqz Frequency response of digital filters 6 342 A abs 6 2 6 11 algorithm filtering in SPTool 5 19 aliased sinc function See Dirichlet function aliasing and impulse invariance 2 41 preventing during resampling 4 21 reducing with analytic signal 4 37 all pole filter SeelIR filter all zero filter See FIR filter am 4 29 AM Seeamplitude modulation amdsb sc 4 29 6 218 amdsb tc 429 6 218 amplitude demodulation double side band suppressed carrier 6 98 double side band transmitted carrier 6 98 single side band 6 98 amplitude modulation 4 29 double side band suppressed carrier 6 218 double side band transmitted carrier 6 218 single side band 6 218 amssb 4 29 6 218 analog filter Bessel 6 16 Butterworth 6 30 Chebyshev type 6 52 Chebyshev type I1 6 57 converting to digital 2 41 6 177 design 2 7 Bessel 2 11 6 16 Butterworth 6 29 Chebyshev type 6 51 Chebyshev type I1 6 57 elliptic 6 110 6 111 inverse 6 186 frequency response 1 26 6 156 order estimation Butterworth 6 35 Chebyshev type 6 42 Chebyshev type 6 47 elliptic 6 118 representational models 1 40 analog frequency xvii analog prototype 2 38 Bessel filter 2 11 6 15 Butterworth filter 2 8 6 28 Chebyshev type filter 2 9 6 40 Chebyshev type II filter 2 10 6 45 conversion to
73. 5 36 You can also position a ruler by specifying parameters in the edit boxes in the Rulers panel The parameters are either the x1 and x2 values or the yl and y2 values depending on which ruler control is selected Type the valueor variable for theruler parameter in the x1 and x2 boxes or the yl and y2 boxes See Making Signal Measurements on page 5 37 for details on manipulating the rulers and the parameters you can measure with each one Peaks and Valleys Use these buttons to show or hide the local maxima and or local minima of the currently selected signal filter response or spectrum Only peaks or valleys or both peaks and valleys may be displayed e Click Peaks to toggle showing down or hiding up the maxima of the signal e Click Valleys to toggle showing down or hiding up the minima of the signal In track and slope mode see Making Signal Measurements on page 5 37 the rulers are constrained tothe peaks or valleys In horizontal and vertical mode the peaks and valleys are only visual and do not affect the behavior of the rulers Save Rulers Button Once you ve set up and made a certain set of measurements you may find it useful to save them for future reference Use the Save Rulers button to save a structurein the MATLAB workspace with thefieldsx1 y1 x2 y2 dx dy m peaks andval eys Undefined values are set toNaN 1 Click Save Rulers tosave the current measurements as a variablein the wor
74. 50 B 40 5842 a 21 94 0 07886 a 21 50 gt a0221 0 a lt 21 For a transition width of Aw rad sec use the length a 8 n 1 2 28540 Filters designed using these heuristics will meet the specifications approximately but you should verify this To design a lowpass filter with cutoff frequency 0 52 rad sec transition width 0 27 rad sec and 40 dB of attenuation in the stopband try n wn beta kaiserord 0 4 0 6 pi 1 0 0 01 0 01 2 pi h firl n wn kaiser nt1l beta noscale Thekai serord function estimates the filter order cutoff frequency and K aiser window beta parameter needed to meet a given set of frequency domain specifications 4 7 4 Special Topics 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 specifications H f fregz h 1 512 2 plot f 20 logl0 abs H grid FIR Design using Kaiser Window 20 T T 40 dB 40H A Magnitude dB 100 L L L L L 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized Frequency Nyquist 1 For details on kai ser ord see the reference description in Chapter 6 4 8 W indows Chebyshev Window The Chebyshev window minimizes the mainlobe width given a particular sidelobe height It is characterized by an equiripple behavior that is its sidelobes all have the same height The chebwi n function with le
75. AE Fie ii ain Fant uat T lfa Wa grids o 0 1 2 a3 hal 1 Freinc Rulers panel including controls for measuring filter responses 5 75 5 Interactive Tools 5 76 The filters magnitude and phase plots are displayed The frequency axis of the plots is set to linear and the frequency axis range is set to 0 Fs 2 You can choose to display one or any combination of the six available subplots by using the check boxes in the Plots panel and you can modify many of the plot display characteristics using the pop up menus in the Plots panel and the Frequency Axis panel Menus File Menu UseClose fromthe File menu toclosethe Filter Viewer Settings you changed and saved using the Preferences window in SPTool are saved and used the next time you open a Filter Viewer Window Menu Use the Window menu to select a currently open MATLAB Figure window Filter Identification Panel This panel displays the variable names and the highest sampling frequency of the currently selected filters To change names or sampling frequencies use Name or Sampling Frequency from the Edit menu in SPTool Plots Panel The check boxes in this panel select the subplots to display in the main plots area Any combination of subplots may be displayed To display a subplot check the box at the left of the plot description Using the Filter Viewer Interactive Filter Analysis There are six available subplots e Magn
76. B C D ellip n Rp Rs Wn or A B C D ellip n Rp Rs Wn ftype wheredA B C andD are x n 1 Ax n Buln y n Cx n Du n and u is the input x is the state vector and y is the output Analog Domain b a ellip n Rp Rs Wn s designs an ordern lowpass analog elliptic filter with cutoff frequency Wn and returns the filter coefficients in the length n 1 row vectors b anda in descending powers of s _ Bis _ bs b 2 s b n 1 H s ACs ss 4 a 2 s a n 1 The cutoff frequency is the edge of the passband at which the magnitude response of the filter is Rp dB For ell i p the cutoff frequency Wn must be greater than 0 6 111 ellip Examples 6 112 If Wn is atwo element vector with wl lt w2 thenellip n Rp Rs Wn s returns an order 2 n bandpass analog filter with passband w1 lt lt w2 b a ellip n Rp Rs Wn ftype s designs a highpass or bandstop filter wheref type is e high for a highpass analog filter with cutoff frequency Wn e stop for an order 2 n bandstop analog filter Wn is a two element vector wl w2 specifying the stopband w1 lt lt w2 With different numbers of output arguments el i p directly obtains other realizations of the analogfilter To obtain zero pole gain form usethree output arguments z p k ellip n Rp Rs Wn s or z p k ellip n Rp Rs Wn ftype s returns the zeros and poles in length n or 2 n column
77. Frequency field 4 Click OK The signal is imported into SPTool with the specified name and sampling frequency 5 Toimport another variable select Import again click the From Workspace or From File radio button and repeat steps 1 through 4 for each variable that you want to load into SPTool NOTE When you re importing from the workspace you can specify either a variable or a value for each data field When you re importing from a disk you can only specify variables 5 11 5 Interactive Tools Importing a Signal When you import a signal you specify e A variable name for the signal data or the signal data values in the Data field e A variable or a value for the signal s sampling frequency in the Sampling Frequency field Importing a Filter When you import a filter first select the appropriate filter form from the Form pop up menu 5 12 Using SPTool Each filter form requires different variables e For Transfer Function you specify A variable name or a value for the numerator in the Numerator field A variable name or a value for the denominator in the Denominator field e For State Space you specify A variable name or a value for each matrix in the A Matrix B Matrix C Matrix and D Matrix fields e For Zeros Poles Gain you specify A variable name or a value for the zeros in the Zeros field A variable name or a value for the poles in the Poles field A variable name or a valu
78. IfFp ispresent k 2 pi Fp tan pi Fp Fs otherwisek 2 Fs p 2 It strips any zeros at plus or minus infinity using z z find finite z 3 It transforms the zeros poles and gain using pd 1l p k 1 p k zd l z k 1 z k kd real k prod fs z prod fs p 4 It adds extra zeros at 1 so the resulting system has equivalent numerator and denominator order bilinear Diagnostics See Also State Space Algorithm For a system in state space form bi i near performs two steps 1 Iffp ispresent k 2 pi Fp tan pi Fp Fs elsek 2 Fs 2 It computes Ad 8d Cd and Dd in terms of A 8 C andD using Djs ter 7 tJ s D bilinear implements these relations using conventional MATLAB statements Thescalarr is arbitrary bilinear usessqrt 2 k toensure good quantization noise properties in the resulting system bilinear requires that the numerator order be no greater than the denominator order If this is not the case bi i near displays Numerator cannot be higher order than denomi nator For bilinear to distinguish between the zero pole gain and transfer function linear system formats the first two input parameters must be vectors with the same orientation in these cases If this is not the case bil i near displays First two arguments must have the same orientation i mpi nvar Impulse invariance method of analog to digital filter conversion p2bp Lowpass to bandpass analog filter transformation p2bs Lo
79. Passband ripple dB Stopband attenuation dB Contains 1 if the filter order was specified manually i e the Minimum Order box in the Specifications panel was not checked Contains 0 if the filter order was computed automatically Contains 1 for lowpass 2 for highpass 3 for bandpass or 4 for bandstop 3 dB frequency for Butterworth IIR designs Vector of Kaiser window coefficients Cutoff frequency for the Kaiser window FIR filter when setOrderFlag 1 Vector of weights one weight per frequency band Using the Filter Designer Interactive Filter Design Viewing Frequency Response Plots It is often useful to view a filter s frequency response impulse response and step response during the filter design process You can use the Filter Viewer to view frequency domain information about filters in the Filter Designer 1 Activate SPTool from the Window menu 2 Makesure the filters you want to analyze are selected in the Filters list 3 Click View in the Filter panel The Filter Viewer is activated with the selected filters displayed 4 Toedit one of the filters you re viewing you can reactivate the F ilter Designer from the Window menu in the Filter Viewer 5 When you want to review a filter s characteristics after you ve edited it reactivate the Filter Viewer from the Window menu in the Filter Designer When the Filter Viewer is open at the same time that the Filter Designer is open they both display the s
80. Processing Toolbox User s Guide median Median value see the online MATLAB Function Reference 1 Pratt W K Digital Image Processing New York J ohn Wiley amp Sons 1978 Pgs 330 333 6 217 modulate Purpose Syntax Description 6 218 Modulation for communications simulation y modu y modu yt y modu y modu ate x Fc Fs method ate x Fc Fs method opt modul ate x Fc Fs ate x Fc Fs method and ate x Fc Fs method opt modulate the real message signal x with a carrier frequency Fc and sampling frequency Fs using one of the options listed below for met hod Note that some methods accept an option opt amdsb sc or am amdsb tc ams sb Amplitude modulation double sideband suppressed carrier Multiplies x by a sinusoid of frequency Fc y x cos 2 pi Fc t Amplitude modulation double sideband transmitted carrier Subtracts scalar opt fromx and multiplies the result by a sinusoid of frequency Fc y x opt cos 2 pi Fc t If theopt parameter is not present modul ate uses a default of mi n mi n x sothat the message signal x opt is entirely non negative and has a minimum value of 0 Amplitude modulation single sideband Multiplies x by a sinusoid of frequency Fc and adds the result to the Hilbert transform of x multiplied by a phase shifted sinusoid of frequency Fc y x cos 2 pi Fc t ti mag hilbert x sin 2 pi Fc t This ef
81. Rulers 5 37 5 Interactive Tools 5 38 panel are x1 the position of ruler 1 on the x axis x2 the position of ruler 2 on the x axis and dx the value of x2 x1 Click Vertical to put the rulers in vertical mode In vertical mode you may change the x values of the rulers that is their horizontal position As the x1 and x2 values change the value of dx changes automatically Change the x1 and x2 values by either e Dragging the rulers tothe left and the right with the mouse or e Entering their values in the x1 and x2 edit boxes in the Rulers panel Ruler Controls Horizontal There are two horizontal rulers called ruler 1 and ruler 2 When horizontal rulers arein use the measurements displayed in the Using SPTool Rulers panel are y1 the position of ruler 1 on the y axis y2 the position of ruler 2 on the y axis and dy the value of y2 y1 Click Horizontal to put the rulers in horizontal mode In horizontal mode you may change the y values of the rulers that is their vertical position As the y1 and y2 values change the value of dy changes automatically Change the y1 and y2 values by either e Dragging the rulers up and down with the mouse or e Entering their values in the y1 and y2 edit boxes in the Rulers panel Ruler Controls Track There are two vertical rulers called ruler 1 and ruler 2 with a marker on each that shows the y values of the signal at the x values of the rulers When
82. Sampled aperiodic rectangle generator Sawtooth or triangle wave generator Sine of vector matrix elements See the online MATLAB Function Reference Square wave generator Sampled aperiodic triangle generator 6 277 sos2ss Purpose Syntax Description 6 278 Second order section to state space conversion A B C D sos2ss sos sos2ss converts a second order section representation of a given system to an equivalent state space representation A B C D sos2ss sos converts the systems os in second order section form toa single input single output state space representation x n 1 Ax n Bu n yin Cx n Du n The discrete transfer function in second order section form is given by bo b lip 2 l l Z Z H z H z Ok Ik I 2k 7 kel A0k T Alk akz k 1 where L is the number of rows insos sos is a L by 6 matrix organized as boi bi 521 a 41 azn bor b2 bn ap an2 av SOS oes bor On b2L 4oL 4L aL The entries of sos must be real for proper conversion to state space The returned matrix A is size N by N where N 2L 1 B is a length N 1 column vector C is a length N 1 row vector and D is a scalar sos2ss Compute the state space representation of a simple second order section form 1 1 1 0 1 2 3 1 110 1 sos2ss sos 3 1463 0 0 0 0 0 2 8284 0 8990 0 3178 0 0 3178 0 5 6569 1 2020 2 5106 s0s2ss first finds the zeros and poles of the second order sections us
83. Save Rulers eb J 500 1000 1500 2000 2500 Frequency Notice that the spectrum s signal identification information including its name its type and its sampling frequency is displayed above the 5 107 5 Interactive Tools 5 108 Parameters panel and the spectrum s name is displayed both above the main axes display area and in the Selection pop up menu Thespectrum estimate is within 2 or 3 dB of 0 sothe noise has a fairly flat spectrum Reactivate SPT ool by selecting it from the Window menu in the Spectrum Viewer Click on the bl noi se signal in the Signals list of SPTool to select it Click Create in the Spectra panel The Spectrum Viewer is again activated and a spectrum object spect 2 corresponding to theb noise signal is created in the Spectra list The spectrum is not computed or displayed yet Click Apply in the Spectrum Viewer to displays pect 2 The spectrum of theb noi se signal is displayed in the main axes display area E Spectrum Viewer AEE Fie Options Window Selection spect2 a Color Signal blnoise Rulers 5000 by 1 real Fs 5000 Bee vertical _ Horizontal TON e af Track Slope Welch E x1 834 96094 Nfft 1024 R rae y1 0 81773082 win 256 y 2 Window hanning T 2 1665 0391 y2 75 394302 Overlap 0 dx 830 07812 Detrending dy 74 576571 Scaling Unbiased T Conf Int 5 ae ye i 30 e Save
84. Signal Processing Principles Algorithms and Applications Englewood Cliffs NJ Prentice Hall 1996 5 Welch P D TheUseof Fast Fourier Transform for the Estimation of Power Spectra A Method Based on Time Averaging Over Short Modified Periodograms IEEE Trans Audio Electroacoust Vol AU 15 J une 1967 Pgs 70 73 3 26 Special Topics Windows 00 0 tee 4 2 BasSiC Shapes ss gic b ergs Sats es tees oh et is a 4 2 Generalized Cosine Windows 0 0c e eee eee 4 4 Kaiser Window 0 006 c eee 4 4 Chebyshev Window 0 000 cece tees 4 9 Parametric Modeling 0000 e eee eeee 4 10 Time Domain Based Modeling 0000 eee eens 4 11 Frequency Domain Based Modeling 00ceeeee 4 16 Resampling 0000 e eee eee 4 20 Cepstrum Analysis 0 00 cece eee ee 4 23 Inverse Complex CepstruM 0 2 2 00 cee ee 4 25 FFT Based Time Frequency Analysis 4 26 Median Filtering 0 00 0 cece eee eee 4 27 Communications Applications 4 28 Deconvolution 00 00 cece eee 4 32 Specialized Transforms 0 20 0 000 4 33 Chirp z Transform 0 0 60 c eee 4 33 Discrete Cosine Transform 00 cece eee 4 35 Hilbert Transform 0 0000 cece eee 4 37 References oc ai he eb i Sh eA a Bees 4 39 4 Special Topics 4 2 Windows In both digital filte
85. T Tranfer Function Estimate dB 45 L i f 0 i i i fi f 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Frequency Algorithm tfe uses a four step algorithm 1 It multiplies the detrended sections by wi ndow 2 It takes the length nf ft FFT of each section 3 It averages the squares of the spectra of thex sections to form Pxx and averages the products of the spectra of thex andy sections toformPxy 4 It calculatesTxy Txy Pxy Pxx 6 313 tfe Diagnostics See Also 6 314 An appropriate diagnostic message is displayed when incorrect arguments are used Requires Requires Requires Requires Requires etfe cohere csd psd spa window s length to be no greater than the FFT length NOVERLAP to be strictly less than the window length positive integer values for NFFT and NOVERLAP vector either row or column input inputs X and Y to have the same length Compute empirical transfer function estimate and periodogram see System dentification Tool box User s Guide Estimate magnitude squared coherence function between two signals Estimate the cross spectral density CSD of two signals Estimate the power spectral density PSD of a signal using Welch s method Perform spectral analysis for input output data see System dentification Toolbox User s Guide triang Purpose Syntax Description See Also References Triangular window w triang n triang n ret
86. This method is more expensive computationally than Welch s method because of the cost of computing the discrete prolate spheroidal sequences DPSSs also known as Slepian sequences F or long data series 10 000 points or more it is useful to compute the DPSSs once and save them in a MAT file The M files dpsssave dpssload dpssdir anddpssclear are provided to keep a database of saved DPSSs in the MAT filedpss mat Yule Walker AR Method TheYuleWalke AR method is an autoregressivetechniquefor spectral density estimation see Marple 2 Chapter 7 and Proakis 4 Section 12 3 2 This method solves for the AR model parameters by the autocorrelation method The Yule Walker AR estimate is obtained by solution of the normal equations r 1 r 2 r n a 2 r 2 2 D r n D a 3 _ r 3 r n r n 1 r J an i r n 1 Here a 1 a 2 a n 1 is a vector of autoregressive coefficients the elements of vector r r 1 r 2 r n 1 are correlations and the left hand side autocorrelation matrix is Hermitian Toeplitz and positive definite 3 19 3 Statistical Signal Processing 3 20 The spectral density estimate is 1 Pyurear f 5 la ecf where e f is a complex sinusoid The toolbox function pyul ear implements the Yule Walker AR method For example compare the spectrum of a speech signal using Welch s method and Yule Walker AR load mtlb P1 f psd mtlb 1024 Fs 256 P2 f pyul
87. a n 1 The filter coefficients are ordered in descending powers of z Ifn is unspecified pc uses as adefaultn ength x 1 If x is a matrix containing a separate signal in each column pc returns a model estimate for each column in the rows of a and a row vector of gains g Model a nonrecursive FIR filter with an all pole IIR filter using pc n cl ds Sapo ia a g pc x 15 H w fregz x 1 512 Hl w freqz g a 512 6 211 Ipc Algorithm 6 212 Plot the FIR response with a solid line and the IIR response with a dashed line plot w pi abs H w pi abs H1 Comparison of MA and AR Frequency Responses 0 0 2 0 4 0 6 0 8 1 Normalized Frequency pc uses the autocorrelation method of autoregressive AR modeling to find the filter coefficients This techniqueis also called the Yule Walker AR method of spectral estimation The filter generated is stable However the generated filter might not model the process exactly even if the data sequence is truly an AR process of the correct order This is because the autocorrelation method implicitly windows the data that is it assumes that signal samples beyond the length of x are 0 pc computes the least squares solution to Xaz b Ipc where x1 O 0 x 2 x 1 1 1 x 2 0 A xm Es xD as aa gt b k ay i a a n 1 0 O O Xm and m is the length of x Solving the least squares problem via the normal equat
88. a peak of height 1 at apanar frequency Wo the estimate will have approximate height Wo w 4 at that frequency provided the window W is narrow with respect to the spacing between the peak and other spectral features So to obtain an estimate of the height of the original peaks multiply the result of psd by nor m w 2 sum w 2 where w is the 3 11 3 Statistical Signal Processing 3 12 window vector This scaling is independent of window length and shape F or example wl hanning 256 w2 hanning 500 Pxx1 f1 psd xn 256 Fs wl 128 none Pxx2 f2 psd xn 1024 Fs w2 250 none plot f1 10 1og10 Pxx1l norm wl 2 sum wl 2 plot f2 10 1og10 Pxx2 norm w2 2 sum w2 2 4 L L L L L L L L L 50 100 150 200 250 300 350 400 450 500 4 L L L L i L L i L K 50 100 150 200 250 300 350 400 450 500 In both plots which show the spectrum at positive frequencies only the negative frequencies are the same the higher frequency peak has a value of 0 dB and the lower frequency peak is at 6 dB The 120 Hz sinusoid height of 0 dB corresponds to a squared amplitude of 1 This results from the sinusoid of amplitude 2 having complex exponential components of amplitude 1 at both positive and negative frequency Similarly the 50 Hz sinusoid has both positive and negative frequency components with squared amplitude of f z or 10 log10 25 6 dB as shown in the plot Also note t
89. a sampling frequency or a vector of arbitrary frequency points The example below finds the 256 point frequency response for a 12th order Chebyshev type filter The call tof r eqz specifies a sampling frequency Fs of 1000 Hz b a cheby1 12 0 5 200 500 h f freqz b a 256 1000 Because the parameter list includes a sampling frequency f r eqz returns a vector f that contains the 256 frequency points between 0 andFs 2 used in the frequency response calculation Frequency Response Frequency Normalization This toolbox uses the convention that unit frequency is the Nyquist frequency defined as half the sampling frequency The cutoff frequency parameter for all basic filter design functions is normalized by the Nyquist frequency For a system with a 1000 Hz sampling frequency for example 300 Hz is 300 500 0 6 To convert normalized frequency to angular frequency around the unit circle multiply by z To convert normalized frequency back to Hertz multiply by half the sample frequency If you call f reqz with no output arguments it automatically plots both magnitude versus frequency and phase versus frequency For example a ninth order Butterworth lowpass filter with a cutoff frequency of 400 Hz based on a 2000 Hz sampling frequency is b a butter 9 400 1000 Now calculate the 256 point compl ex frequency response for this filter and plot the magnitude and phase with a call tof reqz freqz b a
90. a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Rp Passband ripple in decibels This value is the maximum permissible passband loss in decibels The passband is 0 lt w lt Wp Rs Stopband attenuation in decibels This value is the number of decibels the stopband is down from the passband The stopband isWs lt w lt 1 Digital Domain n Wn cheb2ord Wp Ws Rp Rs returns the order n of the lowest order Chebyshev filter that loses no more than Rp dB in the passband and has at least Rs dB of attenuation in thestopband The passband runs from 0 toWp and the stopband runs from Ws to 1 the Nyquist frequency cheb2ord also returns Wn the Chebyshev type II cutoff frequency that allows cheby2 to achieve the given specifications Usecheb2ord for lowpass highpass bandpass and bandstop filters For highpass filters Wp is greater than Ws For bandpass and bandstop filters Wp and Ws aretwo element vectors that specify the corner frequencies at both edges of the filter lower frequency edge first For the band filters cheb2ord returns Wn as a two element row vector for input tocheby2 If filter specifications call for a bandpass or bandstop filter with unequal ripple in each of thepassbands or stopbands design the filter as separate lowpass and highpass sections and cascade the two filters together cheb2ord Examples Analog Domain n Wn cheb2ord Wp Ws Rp Rs s
91. according to true time and frequency B specgram a f Fs window noverlap computes the spectrogram at the frequencies specified inf using either the chirp z transform for more than 20 evenly spaced frequencies or a polyphase decimation filter bank f is a vector of frequencies in Hertz it must have at least two elements specgr am calculates the spectrogram for a given signal as follows 1 It splits the signal into overlapping sections and applies the window specified by the wi ndow parameter to each section 2 It computes the discrete time F ourier transform of each section with a length nf f t FFT toproducean estimate of the short term frequency content of the signal these transforms make up the columns of B specgram zero pads the windowed sections ifnfft gt ength window so the quantity length window noverlap specifies by how many samples specgram shifts the window 3 For real input s pecgramtruncates the spectrogram to thefirst nf ft 2 1 points for nf ft evenand nfft 1 2 fornfft odd specgram Example Plot the spectrogram of a digitized speech signal load mti b specgram mtIb 512 Fs kaiser 500 5 475 Spectrogram Frequency 0 0 05 0 1 0 15 0 2 0 25 0 3 0 35 0 4 0 45 Time Diagnostics An appropriate diagnostic message is displayed when incorrect arguments are used Requires window s length to be no greater than the FFT length Requires NOVERLAP to be strictly less than the window length Req
92. activated by clicking the Mouse Zoom button It does not turn off after you click in the display area and a zoom operation occurs you can continue to click and zoom without resetting the Mouse Zoom button You can change whether zooming is one time or persistent by selecting Preferences from the File menu and toggling Stay in Zoom mode After 5 31 5 Interactive Tools 5 32 Zoom in the preferences panels for the Signal Browser the Spectrum Viewer the Filter Designer and the Filter Viewer When Stay in Zoom mode After Zoom is selected zooming is persistent To turn off mouse Zooming when Stay in Zoom mode After Zoom is selected click the Mouse Zoom button Passband Zoom Filter Designer Click once to zoom in on the passband of the response Both thex and y limits of the main axes are changed so that the passband fills the main axes Thereis no stopband zoom button To zoom the stopband use standard Mouse Zoom centering the crosshair on the area of the stopband you want to view If you arein passband zoom first press Full View to return to the standard view Ruler Controls The Signal Browser Filter Viewer and Spectrum Viewer share a common set of ruler controls Use the rulers to make measurements on the signals or spectra in the main axes display area The ruler controls give you a variety of ways to read and control the values of the rulers in the main axes With the rulers you can measure such information as
93. amp Sons 1975 Pgs 123 126 latc2tf Purpose Syntax Description See Also Lattice filter to transfer function conversion num den latc2tf k v num den latc2tf k iir num latc2tf k fir num latc2tf k num den latc2tf k v finds the transfer function numerator num and denominator den fromthe IIR lattice coefficients k and ladder coefficients v num den latc2tf k iir assumesthatk is associated with an all pole IIR lattice filter num latc2tf k fir and num latc2tf k find thetransfer function numerators from the FIR lattice coefficients specified by k latcfilt Lattice and lattice ladder filter implementation tf2latc Transfer function to lattice filter conversion 6 199 latcfilt Purpose Syntax Description See Also 6 200 Lattice and lattice ladder filter implementation f g latcfilt k x f g latcfilt k v x f g latcfilt k 1 x f g latcfilt k x filtersx with the FIR lattice coefficients in vector k f isthe forward lattice filter result and g is the backward filter result Ifk andx are vectors the result is a Signal vector Matrix arguments are permitted under the following rules e Ifx isa matrix andk isa vector each column of x is processed through the lattice filter specified by k e Ifx isa vector andk is a matrix each column ofk is used to filter x anda signal matrix is returned e Ifx andk are both matrices with
94. analog filters whereas for the digital case frequency is normalized the Nyquist frequency is equal to 1 Hz bz az chebyl 5 3 0 1 0 5 All of the complete design functions call bi i near internally They prewarp the band edges as needed to obtain the correct digital filter See Chapter 6 for more on these functions References References 1 Karam L J andJ H McClellan Complex Chebyshev Approximation for FIR Filter Design IEEE Trans on Circuits and Systems II March 1995 2 Selesnick I W and C S Burrus Generalized Digital Butterworth F ilter Design Proceedings of the EEE Int Conf Acoust Speech Signal Processing Vol 3 May 1996 3 Selesnick I W M Lang and C S Burrus Constrained Least Square Design of FIR Filters without Specified Transition Bands Proceedings of thel EEE Int Conf Acoust Speech Signal Processing Vol 2 May 1995 Pgs 1260 1263 2 Filter Design 2 46 Statistical Signal Processing Correlation and Covariance 2 0 3 2 Bias and Normalization 0000 c eee ee 3 3 Multiple Channels 0 000 cece eee ee 3 4 Spectral Analysis 0 000 c cece 3 5 Welch s Method 000 ccc cee eee ee tenet eens 3 6 Multitaper Method 0 0 00 c eee eee eee 3 16 YuleWalker AR Method 00 0000 cece eee eee 3 19 Burg Method 000 c eect ees 3 20 MUSIC and Eigenvector Analysis Metho
95. analysis time dependent F ourier transforms and spectrograms median filtering communications applications deconvolution and specialized transforms If you are an experienced toolbox user See Chapter 5 Interactive Tools for an overview of the interactive GUI environment and examples of how to use it for signal viewing filter design and implementation and spectral analysis xiii Before You Begin xiv All toolbox users Use Chapter 6 Reference for locating information on specific functions Reference descriptions include a synopsis of the function s syntax as well as a complete explanation of options and operation Many reference descriptions also include helpful examples a description of the function s algorithm and references to additional reading material Use this manual in conjunction with the software to learn about the powerful features that MATLAB provides Each chapter provides numerous examples that apply the toolbox to representative signal processing tasks Some examples use MATLAB s random number generation function randn In these cases to duplicate the results in the example type randn seed 0 before running the example Installation Installation Toinstall this toolbox on a workstation see the MATLAB Installation Guide for UNIX Toinstall the toolbox on a PC or Macintosh see the MATLAB Installation Guide for PC and Macintosh To determine if the Signal Processing Toolbox
96. b cremez n f lowpass d design a linear phase n 2 d delay filter mul ti band designs a linear phase frequency response filter with arbitrary band amplitudes b cremez n f multiband a and b cremez n f multiband a d Specify vector a containing the desired amplitudes at the band edges in f The desired amplitude at frequencies between pairs of points f k andf k 1 fork odd is the line segment connecting the points f k a k and f k 1 a k 41 differentiator designs a linear phase differentiator For these designs zero frequency must bein a transition band and band weighting is set to be inversely proportional to frequency b cremez n f differentiator Fs and b cremez n f differentiator Fs d specifythesampleratef s used to determine the slope of the differentiator response If omitted F s defaults to 1 hil bfilt designs a linear phase Hilbert transform filter response F or Hilbert designs zero frequency must bein a transition band b cremez n f hilbfilt and b cremez N F hilbfilt d design alinear phase n 2 d delay Hilbert transform filter cremez n f a w iSasynonym for cremez n f multiband a w cremez b cremez sym imposes asymmetry constraint on the impulse response of the design where s ym may be one of the following e none indicates no symmetry constraint This is the default if any negative band edge frequencies are pa
97. default of 2 Hz Pxx psd x dflag specifies a detrend option wheredf ag is e i near to remove the best straight line fit from the pre windowed sections of x e mean to remove the mean from the pre windowed sections of x e none for no detrending default Thedf ag parameter must appear last in the list of input arguments ps d recognizes a df ag string no matter how many intermediate arguments are omitted Pxx Pxxc f psd x nfft Fs window noverlap p wherep isa positive scalar between 0 and 1 returns a vector Pxxc that contains an estimate of the p 100 percent confidence interval for Pxx Pxxc is atwo column matrix that is the same length as Pxx The interval Pxxc 1 Pxxc 2 covers the true PSD with probability p plot f Pxx Pxxc plots the power spectrum inside the p 100 percent confidence interval If unspecified p defaults to 0 95 psd psd x with no output arguments plots the PSD versus frequency in the current figure window If the p parameter is specified the plot includes the confidence interval Example Generate a colored noise signal and plot its PSD with a confidence interval of 95 Specify a length 1024 FFT a 512 point Kaiser window with no overlap and a sampling frequency of 10 kHz h firl 30 0 2 boxcar 31 design a lowpass filter r randn 16384 1 white noise x filter h 1 r color the noise psd x 1024 10000 kaiser 512 5 0 0 95 Power Spectral Density E
98. design passband ripple cheby2 Chebyshev type II filter design stopband ripple ellip Elliptic Cauer filter design invfreqz Discrete time filter identification from frequency data levinson Levinson Durbin recursion pc Linear prediction coefficients st mc b Linear model using Steiglitz McBride iteration References 1 Parks T W and C S Burrus Digital Filter Design New York J ohn Wiley amp Sons 1987 Pgs 226 228 6 238 psd Purpose Syntax Description Estimate the power spectral density PSD of a signal using Welch s method Pxx psd x Pxx psd x nfft Pxx f psd x nfft Fs Pxx psd x nfft Fs wi ndow Pxx psd x nfft Fs window noverl ap Pxx psd x dflag Pxx Pxxc f psd x nfft Fs window noverl ap p psd x Pxx psd x estimates the power spectrum of the sequencex using the Welch method of spectral estimation Pxx psd x uses the following default values enfft min 256 length x e Fs 2 e window hanning nfft e noverlap 0 nfft specifies the FFT length that psd uses This value determines the frequencies at which the power spectrum is estimated Fs is a scalar that specifies the sampling frequency wi ndow specifies a windowing function and thenumber of samples ps d uses in its sectioning of thex vector nover I ap isthe number of samples by which the sections overlap Any arguments that you omit from the end of the input parameter list use
99. dimensional 6 329 unbiased 3 3 cross covariance 6 330 multiple channels 3 4 csd 3 6 3 13 6 6 6 84 Index CSD Seecross spectral density cutoff frequency 2 38 defined 6 16 for Kaiser window filter 5 65 czt 4 34 6 6 6 89 CZT Seechirp z transform D data duplicating in SPTool 5 16 editing in SPTool 5 14 5 16 entering 1 13 exporting from SPTool 5 7 importing 1 13 importing into SPTool 5 5 5 7 5 8 measuring in SPTool 5 30 multichannel 1 4 1 7 viewing in SPTool 5 30 data compression 4 10 data matrix 1 4 1 7 data vector 1 4 dct 4 35 6 6 6 92 example 4 36 deci mate 6 8 6 94 decimation 6 94 FIR filter for 6 184 deconv 4 32 6 8 6 97 example 4 32 deconvolution 4 32 6 97 default plot in Spectrum Viewer 5 93 delay adding to signal 2 25 group 1 28 noninteger 2 26 phase 1 28 demod 4 28 4 29 6 8 6 98 example 4 30 demodulation 4 29 6 98 example 4 30 methods 4 29 6 98 design generalized filter 2 5 designed filter in SPTool 5 15 detrend 6 8 6 101 DFT Seediscrete F ourier transform df tmt x 6 6 6 102 difference equation relation to transfer function 1 32 differentiator 2 26 6 151 6 257 Digital Audio Tape standard 4 20 digital filter anti causal 1 20 as convolution matrix 1 40 Butterworth 6 29 cascade 1 37 Chebyshev type 6 51 Chebyshev type II 6 56 coefficients 1 15 design 2 2 elliptic 6 110 FIR 2 16 compared to IIR 2 16 fixed point implementation 1 37 frequency response 1 24 group dela
100. dimensional signal or image processing see the reference descriptions in Chapter 6 for details It is sometimes convenient to rearrange the output of thef ft orf f t2 function so the zero frequency component is at the center of the sequence The MATLAB functionf ft shift moves the zero frequency component tothe center of a vector or matrix 1 45 1 Signal Processing Basics References Algorithm development for the Signal Processing Toolbox has drawn heavily upon the references listed below All are recommended to the interested reader who needs to know more about signal processing than is covered in this manual 1 Crochiere R E and L R Rabiner Multi RateSignal Processing Englewood Cliffs NJ Prentice Hall 1983 Pgs 88 91 2 IEEE Programs for Digital Signal Processing IEEE Press New York ohn Wiley amp Sons 1979 3 Jackson L B Digital Filters and Signal Processing Third Ed Boston Kluwer Academic Publishers 1989 4 Kay S M Modern Spectral Estimation Englewood Cliffs NJ Prentice Hall 1988 5 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 6 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 7 Pratt W K Digital Image Processing New York J ohn Wiley amp Sons 1991 8 Percival D B and A T Walden Spectral Analysis for Physical Applications Multitaper and Conventional Univariate Techniq
101. dpssclear dpssdir dpssload dpsssave pmt m 1 Percival D Remove discrete prolate spheroidal sequences from database Discrete prolate spheroidal sequences database directory Load discrete prolate spheroidal sequences from database Save discrete prolate spheroidal sequences in database Power spectrum estimate using the multitaper method MTM B and A T Walden Spectral Analysis for Physical Applications Multitaper and Conventional UnivariateT echniques Cambridge Cambridge University Press 1993 6 105 dpssclear Purpose Syntax Description See Also 6 106 Remove discrete prolate spheroidal sequences from database dpssclear n nw dpssclear n nw removes sequences with length n and time bandwidth product nw from the DPSS MAT file databasedpss mat dpss Discrete prolate spheroidal sequences Slepian sequences dpssdir Discrete prolate spheroidal sequences database directory dpssload Load discrete prolate spheroidal sequences from database dpsssave Save discrete prolate spheroidal sequences in database dpssdir Purpose Syntax Description See Also Discrete prolate spheroidal sequences database directory dpssdir dpssdir n dpssdir nw nw dpssdir n nw index dpssdir dpssdir manages the database directory that contains the generated DPSS samples in the DPSS MAT file databasedpss mat dpssdir lists the directory of saved sequences indpss mat d
102. e returns the phase angle in radians To extract and plot the magnitude and phase of a Butterworth filter b a butter 6 300 500 h w freqz b a 512 1000 m abs h p angle h semi logy w m pl ot w p 180 pi 10 200 100 10 0 10 100 10 200 0 100 200 300 400 0 100 200 300 400 Frequency Response Theunwrap function is also useful in frequency analysis unwrap unwraps the phase to make it continuous across 360 phase discontinuities by adding multiples of 360 as needed Tosee how unwrap is useful design a 25th order lowpass FIR filter h firl 25 0 4 Obtain the filter s frequency response with f r eqz and plot the phase in degrees H f fregqz h 1 512 2 plot f angle H 180 pi grid 200 T 150 g 100 50F 0 50H 100F 150f 2 ji L L 1 L 1 L L 1 aa 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 It is difficult to distinguish the 360 jumps an artifact of the arctangent function insideang e from the 180 jumps that signify zeros in the frequency response 1 27 1 Signal Processing Basics 1 28 Useunwrap to eliminate the 360 jumps plot f unwrap angle H 180 pi grid 0 200 600 800 1000F 1200F 1 400 L L L L L L L ji 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 Delay The group delay of a filter is a measure of the aver
103. each column and sqrt diag cov X iS a vector of standard deviations cov x isthe zeroth lag of the covariance function that is the zeroth lag of xcov x n 1 packed into a square array cov x y wherex andy arecolumn vectors of equal length is equivalent to cov x y that is it concatenates x andy in the row direction before its computation cov removes the mean from each column before calculating the results This function is part of the standard MATLAB environment n p size x x x ones n 1 sum x n y x x n 1 corrcoef Correlation coefficient matrix mean Average value see the online MATLAB Function Reference median Median value see the online MATLAB Function Reference std Standard deviation see the online MATLAB Function Reference xcorr Cross correlation function estimate XCOV Cross covariance function estimate equal to mean removed cross correlation 6 75 cplx pair Purpose Syntax Description Example Diagnostics 6 76 Group complex numbers into complex conjugate pairs y cpl xpair x cpl xpair x tol I y cplxpair x returnsx with complex conjugate pairs grouped together cpl xpair orders the conjugate pairs by increasing real part Within a pair the element with negative imaginary part comes first The function returns all purely real values following all the complex pairs y cpl xpair x tol includes a tolerance tol for determining which
104. filter order estimation yul ewal k Recursive digital filter design 1 IEEE Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 Algorithm 5 1 2 IEEE Sdected Papers in Digital Signal Processing Il IEEE Press New York J ohn Wiley amp Sons 1979 3 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 Pg 83 4 Rabiner L R J H McClellan and T W Parks FIR Digital Filter Design Techniques Using Weighted Chebyshev Approximations Proc IEEE 63 1975 5 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 256 266 remezord Purpose Syntax Description Examples Parks McClellan optimal FIR filter order estimation n fo a0 w remezord f a dev n fo a0 w remezord f a dev Fs c remezord f a dev Fs cell n fo a0 w remezord f a dev finds the approximate order normalized frequency band edges frequency band amplitudes and weights that meet input specifications f a anddev to use with ther emez command e f is a vector of frequency band edges between 0 and Fs 2 where Fs is the sampling frequency anda is a vector specifying the desired amplitude on the bands defined by f The length off is twice the length of a minus 2 The desired function is piecewise constant e dev is a vector the same size as a that specifies the maximum allo
105. for more details The standard MATLAB environment contains a function spl i ne that works with irregularly spaced data The MATLAB functioni nt erp1 performs interpolation or table lookup using various methods including linear and cubic interpolation See the online MATLAB Function Reference for information onspline andinterpl C epstrum Analysis Cepstrum Analysis Cepstrum analysis is a nonlinear signal processing technique with a variety of applications in areas such as speech and image processing The Signal Processing Toolbox provides three functions for cepstrum analysis Operation Function Complex cepstrum cceps Real cepstrum rceps Inverse complex cepstrum icceps The complex cepstrum for a sequence x is calculated by finding the complex natural logarithm of the Fourier transform of x then the inverse F ourier transform of the resulting sequence T f log x e7 oJ dw 20 Jn The toolbox function cceps performs this operation estimating the complex cepstrum for an input sequence It returns a real sequence the same size as the input sequence gt xhat cceps x The complex cepstrum transformation is central tothe theory and application of homomorphic systens that is systems that obey certain general rules of superposition See Oppenheim and Schafer 2 for a discussion of the complex cepstrum and homomorphictransformations with details on speech processing applications Try usingcceps in an
106. form the window the low frequency peaks in the frequency domain combine in such a way as to decrease sidelobe height This has the side effect of increasing the mainlobe width The Hamming and Hanning windows are two term generalized cosine windows given by A 0 54 8 0 46 for Hamming andA 0 5 8 0 5 for Hanning C 0 in both cases Thehammi ng and hanni ng functions respectively compute these windows Note that the definition of the generalized cosine window shown in the earlier MATLAB code yields zeros at samples 1 andn forA 0 5 andB 0 5 To eliminate these zeros on the edges of the window hanni ng uses a cosine of frequency 2n N 1 instead of 2x N 1 The Blackman window is a popular three term window given by A 0 42 B8 0 5 C 0 08 Thebl ackman function computes this window Kaiser Window The Kaiser window is an approximation to the prolate spheroidal window for which the ratio of the mainlobe energy tothe sidelobe ener gy is maximized F or a Kaiser window of a particular length the parameter B controls the sidelobe height For a given B thesidelobe height is fixed with respect to window length W indows The statement kai ser n beta computes a length n Kaiser window with parameter beta Examples of Kaiser windows with length 50 and various values for the bet a parameter are n 50 wl kaiser n 1 w2 aiser n 4 w3 kaiser n 9 W1 f freqz wl sum wl 1 512 2 W2 f freqz w2 sum w2 1
107. function given by num andden toa discrete equivalent Row vectorsnumandden specify the coefficients of the numerator and denominator respectively in descending powers of s num s _ num 1 s num nn s num nn 1 den s den 1 s den nd s den nd 1 Fs is the sampling frequency in Hertz bilinear returns the discrete equivalent in row vectors numd and dend in descending powers of z ascending powers of z Fp is the optional match frequency in Hertz for prewarping 6 21 bilinear Algorithm 6 22 State Space Ad Bd Cd Dd bilinear A B C D Fs and Ad Bd Cd Dd bilinear A B C D Fs Fp convert the continuous time state space system in matrices A B C D x Ax Bu y Cx Du to the discrete time system x n 1 Agx n Byun yin Cyx n Dgu n Fs is the sampling frequency in Hertz bi i near returns the discrete equivalent in matrices Ad Bd Cd Dd Fp is the optional match frequency in Hertz for prewarping bilinear uses one of two algorithms depending on the format of the input linear system you supply One algorithm works on the zero pole gain format and the other on the state space format F or transfer function representations bilinear converts to state space form performs the transformation and converts the resulting state space system back to transfer function form Zero Pole Gain Algorithm For a system in zero pole gain form bi I i near performs four steps 1
108. greater thannfft Pxy csd x y nfft Fs window noverlap overlaps the sections of x and y by nover ap samples You can use the empty matrix to specify the default value for any input argument except x or y For example csd x y 10000 is equivalent to csd x but with a sampling frequency of 10 000 Hz instead of the default of 2 Hz Pxy csd x y dflag specifies a detrend option wheredf ag is e i near toremovethe best straight line fit from the prewindowed sections of x andy e mean to remove the mean from the prewindowed sections of x and y e none for no detrending default Thedf ag parameter must appear last in the list of input arguments cs d recognizes a df ag string no matter how many intermediate arguments are omitted Pxy Pxyc f csd x y nfft Fs window noverlap p wherep isa positive scalar between 0 and 1 returns a vector Px yc that contains an estimate of the p 100 percent confidence interval for Pxy Pxyc isa two column matrix thesame length asPxy Theinterval Pxyc 1 Pxyc 2 coversthetrue CSD with probabilityp plot f Pxy Pxyc plots the cross spectrum inside the p 100 percent confidence interval If unspecified p defaults to 0 95 6 85 csd Example 6 86 csd x y plotstheCSD versus frequency in thecurrent figure window If thep parameter is specified the plot includes the confidence interval Generate two colored noise signals and plot their CSD with a confidenc
109. h w fregqz b a 128 plot f m w pi abs h 1 2 0 87 0 6 0 4 0 2 0 1 1 1 1 1 1 1 L 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 yul ewal k performs a least squares fit in the time domain It computes the denominator coefficients using modified Yule Walker equations with correlation coefficients computed by inverse F ourier transformation of the specified frequency response To compute the numerator yul ewal k takes the following steps 1 Computes a numerator polynomial corresponding to an additive decomposition of the power frequency response 2 Evaluates the complete frequency response corresponding to the numerator and denominator polynomials 3 Uses a spectral factorization technique to obtain theimpulse response of the filter 4 Obtains the numerator polynomial by a least squares fit to this impulse response yulewalk See Also butter Butterworth analog and digital filter design chebyl Chebyshev type I filter design passband ripple cheby2 Chebyshev type II filter design stopband ripple ellip Elliptic Cauer filter design fir2 Window based finite impulse response filter design arbitrary response firls Least square linear phase FIR filter design maxf lat Generalized digital Butterworth filter design remez Parks McClellan optimal FIR filter design References 1 Friedlander B and B Porat The Modified Y ule Walker Method of ARMA Spectral Estimation IEEE Transact
110. h x islessthannb filtic pads it with zeros to length nb iflength y islessthanna filtic pads it with zeros to length na Elements of x beyond x nb 1 and elements of y beyond y na 1 are unnecessary sof i tic ignores them Output z is a column vector of length equal to the larger of nb and na z describes the state of the delays given past inputs x and past outputs y z filtic b a y assumes that the input x is O in the past The transposed direct form II structure is x m ym where n 1 is the filter order filtic works for both real and complex inputs 6 135 filtic Algorithm Diagnostics See Also References 6 136 filtic performs a reverse difference equation to obtain the delay states z If any of the input arguments y x b ora iS not a vector that is if any argument is a scalar or array fi tic gives the following error message Requires vector inputs filter Filter data with a recursive IIR or nonrecursive FIR filter filtfilt Zero phase digital filtering 1 Oppenheim A V and R W Schafer Discr amp ee Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 296 301 302 firl Purpose Syntax Description Window based finite impulse response filter design standard response firl n Wn firl n Wn ftype firl n Wn window firl n Wn ftype window firl noscale convo ono oF iT fir1 implements the classical method of
111. iS0 2 n 2 n 1 n f1 f2 freqspace n returns the two dimensional frequency vectors f 1 andf 2 for ann by n matrix For n odd both f 1 andf2 are 1 1 n 2 n 1 1 n Forn even bothf1 andf2 are 1 2 n 1 2 n f1 f2 freqspace mn returnsthetwo dimensional frequency vectors f1 andf2 for an m by n matrix xl yl freqspace n meshgrid and xl yl freqspace mn meshgrid are equivalent to f1 f2 freqspace xl yl meshgrid f1l f2 See the online MATLAB Function Reference for details on the mes hgri d function freqz Frequency response of digital filters invfreqz Discrete time filter identification from frequency data 6 159 freqz Purpose Syntax Description 6 160 Frequency response of digital filters h w freqz b a n h f fregqz b a n Fs h w fregz b a n whole h f fregqz b a n whole Fs h freqz b a w h freqz b a f Fs freqz b a f reqz returns the complex frequency response H e ofa digital filter given the numerator and denominator coefficients in vectorsb anda h w freqz b a n returns then point complex frequency response of the digital filter _ BG _ b nb Iz A z a 1 a 2 z7 alna A z given the coefficient vectors b anda fr eqz returns both h the complex frequency response and w a vector containing then frequency points f r eqz evaluates the frequency response at n points equally spaced ar
112. in the range l and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency The frequencies must bein increasing order andf must have even length The frequency bands span f k tof k 1 fork odd the intervals f k 1 tof k 2 fork odd are transition bands or don t care regions during optimization b cremez n f fresp w uses the real non negative weights in vector w to weight the fit in each frequency band The length of w is half the length of f so thereis exactly one weight per band b cremez n f fresp pl p2 Supplies optional parameters pl p2 tothe frequency response function f resp Predefined fresp frequency response functions are included for a number of common filter designs as described below For all of the predefined frequency response functions the symmetry option sym defaults to even if no negative frequencies are containedinf andd 0 otherwise sym defaults to none See the sym option below for details For all of the predefined frequency response functions d specifies a group delay offset such that the filter response 6 77 cremez 6 78 E Wood has a group delay of n 2 d in units of the sample interval Negative values create less delay positive values create more delay By default d 0 e owpass highpass bandpass bandstop These functions share a common syntax exemplified here by owpass b cremez n f lowpass and
113. is 1 and its minimum value is 1 for n even The magnitude of this function is 1 times the magnitude of the discrete time Fourier transform of then point rectangular window If n is not a positive integer di ric gives the following error message Requires n to be a positive integer cos Cosine of vector matrix elements see the online MATLAB Function Reference gauspuls Gaussian modulated sinusoidal pulse generator pulstran Pulse train generator rect puls Sampled aperiodic rectangle generator sawtooth Sawtooth or triangle wave generator sin Sine of vector matrix elements see the online MATLAB Function Reference sinc Sinc or sin xt rt function Square Square wave generator tripuls Sampled aperiodic triangle generator 6 103 dpss Purpose Syntax Description 6 104 Discrete prolate spheroidal sequences Slepian sequences e v dpss n nw e v dpss n nw k e v dpss n nw k1 k2 e v dpss n nw spline e v dpss n nw spline Ni e v dpss n nw linear e v dpss n nw linear Ni e v dpss trace e v dpss int trace e v dpss n nw generates the first 2 nw discrete prolate spheroidal sequences DPSS of length n in the columns of e and their corresponding concentrations in vector v They are also generated in the DPSS MAT file database dpss mat nw must be less than n 2 e v dpss n nw k returnsthek most band limited se
114. is already installed on your system check for a subdirectory named si gnal within the main toolbox directory or folder Before You Begin Typographical Conventions To Indicate This Manual Uses Example Example code MATLAB output Function names New terms Keys Menu names items and GUI controls Mathematical expressions Monospace type Monospace type Monospace type Italics Boldface with an initial capital letter Boldface with an initial capital letter Variables in italics Functions operators and constants in standard type To assign the value 5 to A enter A 5 MATLAB responds with A Thecos function finds the cosine of each array element An array is an ordered collection of information Press the Return key Choose the File menu This vector represents the polynomial p x 2x 3 Typographical C onventions Technical Notations This manual and the Signal Processing Toolbox functions use the following technical notations Nyquist frequency One half the sampling frequency Most toolbox functions normalize this value to 1 x 1 The first element of a data sequence or filter corresponding to zero lag Q Analog frequency in radians per second w Digital frequency in radians per second f Digital frequency in Hertz Before You Begin xviii Signal Processing Basics Signal Processing Toolbox Central Feat
115. is given in vector h at the frequency points specified in vector w Scalarsnb andna specify the desired orders of the numerator and denominator polynomials Frequency is specified in radians between 0 and z and the length ofh must be the same as the length of w i nvf reqs usesconj h at w to ensure the proper frequency domain symmetry for a real filter b a invfregs h w nb na wt weights the fit errors versus frequency wt iS a vector of weighting factors the same length as w invfreqs h w nb na wt iter and invfreqs h w nb na wt iter tol provide a superior algorithm that guarantees stability of the resulting linear system and searches for the best fit using a numerical iterative scheme Thei ter parameter tellsi nvf reqs toend the iteration when the solution has converged or after i ter iterations whichever comes first i nvf reqs defines convergence as occurring when the invfreqs Remarks Examples norm of the modified gradient vector is less thant ol tol is an optional parameter that defaults to 0 01 To obtain a weight vector of all ones use invfregs h w nb na iter tol invfreqs h w nb na wt iter tol trace displays a textual progress report of the iteration invfregqs h w complex nb na creates a complex filter In this caseno symmetry is enforced and the frequency is specified in radians between r and T When building higher order models using high frequencies it is important to scale
116. linear response filter 2 18 passband 2 11 viewing in Filter Viewer 5 84 Group Delay check box Filter Viewer 5 77 group delay plot 5 77 5 84 grpdelay 1 28 6 3 6 165 GUI Seegraphical user interface GU based tools See interactive tools H hamming 4 2 6 7 6 168 Hamming window 2 20 4 4 6 168 hanning 4 2 6 7 6 169 Hanning window 4 4 6 169 highpass filter analog prototype design 2 6 Bessel 6 16 Butterworth 6 30 6 31 Chebyshev type 6 52 6 53 Chebyshev type I 6 57 6 58 elliptic 6 111 6 112 FIR design with window method 2 21 6 139 transformation from lowpass to 6 207 hilbert 2 26 4 37 6 6 6 170 example 4 38 Hilbert transform 4 33 4 37 6 170 and analytic signal 2 26 and instantaneous attributes 4 38 example 4 38 Hilbert transformer 6 151 6 257 homomorphic systems 4 23 Horizontal button for rulers 5 35 5 37 5 38 l icceps 4 23 4 25 6 8 6 172 example 4 25 idct 4 35 6 6 6 173 ideal lowpass filter 2 18 i fft 1 43 6 6 6175 specifying number of points 1 45 ifft2 1 45 6 6 6 176 IIR filter arbitrary frequency response 2 13 Bessel 2 11 1 13 Index IIR filter cont Butterworth 2 8 Chebyshev type 2 9 Chebyshev type II 2 10 compared to FIR 2 4 design 2 4 direct 2 13 Levinson Durbin recursion 6 201 6 211 multiband 2 13 Prony s method 6 237 Steiglitz M cBride iteration 6 301 Yule Walker 6 333 elliptic 2 10 implementation 6 130 frequency domain 1 22 zero phase 1 20 IIR filter desi
117. m on the data from the previous section xn yields Fs 1000 t 0 1 Fs 1 randn seed 0 xn sin 2 pi 50 t 2 sin 2 pi 120 t randn size t P f pmtm xn 4 1024 Fs plot f 10 10g10 P plot in decibels axis 30 150 20 30 30 25F e 20 a J o T Magnitude dB a T z a 40 60 80 100 120 140 Frequency Hz 3 17 3 Statistical Signal Processing By lowering the time bandwidth product the peaks become narrower P1 f pmtm xn 3 2 1024 Fs plot f 10 1l0g10 P1 plot in decibels axis 30 150 20 30 30 25 A J a l a kej T T Magnitude dB i nN a Eea mee 40 60 80 100 120 140 Frequency Hz Note that the area under the peaks remains about the same as can be seen when both are plotted together on a linear scale plot f P P1 axis 30 150 0 400 400 350F 7 300F 4 N a ej T fi Magnitude N oOo i 150 4 He 100 i L J i i 50 J HEH 4 ih Hy E SAN PERAN l h l 40 60 80 100 120 140 Frequency Hz 3 18 Spectral Analysis This conservation of total power is verifiable numerically sum P ans 1 8447e 03 sum P1 ans 1 8699e 03 Note that total power is only approximately conserved in this case This is because the adaptive weighting procedure that is used to minimize leakage does not strictly conserve total power
118. menu to choose between linear log or decibels scaling of the y axis e Use the Scale pop up menu to choose between linear and log scaling of the x axis e Use the Range pop up menu to choose between the following ranges for the x axis 0 Fs 2 0 Fs or Fs 2 Fs 2 where Fs represents the filter s sampling frequency Viewing Phase Response In addition to displaying magnitude response the Filter Viewer can calculate and plot the filter s phase response Phase response is the angular component of a filter s frequency response To display only a phase response plot for the current filter Using the Filter Viewer Interactive Filter Analysis 1 Click the check box next to the Magnitude option to turn off the magnitude plot 2 Click the check box next to the Phase option to turn on the phase plot and update the display Tik Jg atj By default this plot uses the default phase degrees and the default scaling and range for the frequency axis You can change the following display characteristics of the phase plot e Usethe Phase pop up menu to choose between displaying phase in degrees or radians e Usethe Scale pop up menu to choose between linear and log scaling of the x axis e Use the Range pop up menu to choose between the following ranges for the x axis 0 Fs 2 0 F s or Fs 2 Fs 2 where Fs represents the filter s sampling frequency 5 83 5 Interactive Tools Viewing Group Delay G
119. num den zp2tf z p k finds arational transfer function nn 1 nd 1 num nn 1 s num nn den nd 1 s den nd num s _ num 1 s den s den 1 s given a system in factored transfer function form Z s _ k s Z 1 s Z 2 s Z m p s s pI p 2 8 p n H s Column vector p specifies the pole locations and array Z the zero locations with as many columns as there are outputs The gains for each numerator transfer function are in vector k The zeros and poles must be real or comein complex conjugate pairs The polynomial coefficients are returned in vectors the denominator coefficients in row vector den and the numerator coefficients in matrix num with as many rows as there are columns of z nf values can be used as place holders in Z if some columns have fewer zeros than others The system is converted to transfer function form using pol y with p and the columns of Z ss2tf State space to transfer function conversion ss2zp State space to zero pole gain conversion tf2ss Transfer function to state space conversion tf2zp Transfer function to zero pole gain conversion zp2ss Zero pole gain to state space conversion zplane Purpose Syntax Description Zero pole plot zpl ane z p zpl ane b a hz hp ht zplane z p This function displays the poles and zeros of discrete time systems zplane z p plots the zeros specified in colum
120. of all signals are displayed above the main axes display The first signal in the list is automatically selected in both the main axes display and the panner its name is highlighted in the Selection pop up menu and its color is shown in the Selection display Using the Signal Browser Interactive Signal Analysis When thesignal is an array only the first column is initially displayed in both the main axes and the panner E Signal Browser AEE File Options Window dy 0 071568 Save Rulers Todisplay a different array column or morethan one column of the array click the Array Signals button and specify the column vectors to be displayed see Array Signals Button on page 5 44 All displayed columns of an array are shown in the same color the selected column is emphasized with a heavier line F Race dk i h 4 hadini day lat My why wiu hh PN Paal jiv A t il iu Ni w VAN sara wall Panner 5 49 5 Interactive Tools in both the main axes and the panner and its label is displayed in the Selection pop up menu EJ Signal Browser AE fx File Options Window Rulers i at x1 100 y1 1 1878 27199 y2 1 1162 dx 99 dy 0 071568 Save Rulers Panner 5 50 Using the Signal Browser Interactive Signal Analysis Panner Display The panner displays the entire signal sample at all times 4 3 2 When thesignal in the main axes is zoomed the part of the si
121. of t hresh 1 must be in the range 0 N where N is The column length of xR if xR is a data matrix The matrix sizeifxR is a correlation matrix The window length if xR is a signal vector e Ifthresh 1 gt N thenthresh 2 is a value greater than or equal to 1 that specifies the absolute threshold for splitting the eigenvalues between the signal and noise subspaces That is if a given eigenvalueisless than or equal Spectral Analysis to the product t hresh 2 mink then the given eigenvector is assigned to the noise subspace e lfthresh 1 lt Nandthresh 2 gt 1 thresh 1 still specifies the maximum number of eigenvectors in the signal subspace H owever the threshold test specified by thresh 2 can also assign eigenvectors to the noise subspace e lfthresh 1 gt Nandthresh 2 lt 1 there are no noise eigenvectors This is an invalid case and p music generates an error For complete details on using thet hresh parameter see the reference description of pmusic in Chapter 6 3 25 3 Statistical Signal Processing References 1 Kay S M Modern Spectral Estimation Englewood Cliffs NJ Prentice Hall 1988 2 Marple S L Digital Spectral Analysis Englewood Cliffs NJ Prentice Hall 1987 3 Percival D B and A T Walden Spectral Analysis for Physical Applications Multitaper and Conventional Univariate Techniques Cambridge Cambridge University Press 1993 4 Proakis J G and D G Manolakis Digital
122. orders N and M are determined by the matrix s os H z sos2zp Example Algorithm See Also Compute the poles zeros and gain of a simple system in second order section form sos 1 1 1 1 0 1 2 3 1 1 10 1 z p k sos2zp sos Z 0 5000 0 8660i 0 5000 0 8660i 1 7808 0 2808 p 1 0000 1 0000 9 8990 0 1010 2 sos2zp finds the roots and poles of each second order section using ther oot s command sos 2zp returns the roots and poles with conjugate pairs in consecutive locations with the order of the pairs determined by their row in the sos matrix The gain k is the product of the gains of the sections L pi ea 40k 0525 Second order section to state space conversion sos2tf Second order section to transfer function conversion 552505 State space to second order section conversion 7p2so0s Zero pole gain to second order section conversion 6 283 specgram Purpose Syntax Description 6 284 Time dependent frequency analysis spectrogram B specgram a B specgram a nfft B f specgram a nfft Fs B f t specgram a nfft Fs B specgram a nfft Fs window B specgram a nfft Fs window noverl ap specgram a B specgram a f Fs window noverl ap s pecgram computes the windowed discrete time F ourier transform of a signal using a sliding window The spectrogram is the magnitude of this function B specgram a calculates the spectrogra
123. pole gain 6 282 defined 1 37 in SPTool 5 13 selecting data objects in SPTool 5 15 settings restoring in SPTool 5 29 rulers 5 22 saving in Signal Browser 5 43 saving in SPTool 5 30 signal adding noise 1 6 analytic 4 37 6 170 carrier 4 28 6 98 complex 5 45 continuous analog 1 2 differentiation 2 26 discrete digital 1 2 generating 1 7 importing into SPTool 5 5 5 8 5 10 5 12 linking to spectrum 5 90 measurements 5 37 measurements in Signal Browser 5 35 message 4 28 6 218 multichannel 3 4 naming in SPTool 5 17 peaks 5 36 playing 5 43 plotting 1 6 reconstruction from DCT coefficients 4 36 minimum phase 4 25 6 253 representing in MATLAB 1 4 multichannel 1 4 single channel 1 4 selecting in Signal Browser 5 46 valleys 5 36 viewing in Signal Browser 5 17 5 45 Se also waveform Signal Browser 5 2 5 17 5 42 6 289 activating 5 17 5 42 customizing 5 21 window 5 42 Signal Processing Toolbox 1 2 signal type array 5 15 vector 5 15 sigprefs mat 5 30 sinc 1 10 6 2 6275 bandlimited interpolation example 6 276 sinc function 1 10 6 275 and bandlimited interpolation 6 276 basic example 1 11 defined 1 10 sinusoidal wave 1 9 Slepian sequences See discrete prolate spheroidal sequences Slope button for rulers 5 35 Slope control 5 37 5 40 sonar applications 4 26 sos2ss 1 42 6 3 6 278 sos2tf 1 42 6 3 6 280 sos2zp 1 42 6 3 6 282 Index specgram 4 26 6 9 6 284 example 4 26 6 322 specification lines 5 68
124. rc2poly Polynomial coefficients from reflection coefficients tf2latc Transfer function to lattice filter conversion References 1 McClellan J Parametric Signal Modeling Advanced Topics in Signal Processing Oppenheim A V andJ S Lim ed Englewood Cliffs NJ Prentice Hall 1988 Pgs 20 21 6 235 polystab Purpose Syntax Description Example Algorithm See Also 6 236 Stabilize polynomial b polystab a pol ystab stabilizes a polynomial with respect tothe unit circle it reflects roots with magnitudes greater than 1 inside the unit circle b polystab a wherea isavector of polynomial coefficients normally inthe z domain a z a 1 a 2 zb a na 1 z 4 returns a row vector containing the stabilized polynomial pol yst ab can convert a linear phase filter into a minimum phase filter with the same magnitude response h firl 25 0 4 hmin polystab h norm h norm polystab h pol ystab finds the roots of the polynomial and maps those roots found outside the unit circle to the inside of the unit circle v roots a vs 0 5 sign abs v 1 1 v l vs v vs conj v b a 1 poly v roots Polynomial roots see the online MATLAB Function Reference prony Purpose Syntax Description Example Algorithm Prony s method for time domain IIR filter design b a prony h nb na Prony s method is an algorithm for finding an IIR filter with a pr
125. resample Convolution and polynomial multiplication Decrease the sampling rate for a sequence decimation Filter data with a recursive IIR or nonrecursive FIR filter Increase sampling rate by an integer factor interpolation Interpolation FIR filter design Change sampling rate by any factor 1 Crochiere R E and L R Rabiner Multi Rate Signal Processing Englewood Cliffs NJ Prentice Hall 1983 Pgs 88 91 2 Crochiere R E A General Program to Perform Sampling Rate Conversion of Data by Rational Ratios In Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 Pgs 8 2 1 to 8 2 7 6 321 vco Purpose Syntax Description Example 6 322 Voltage controlled oscillator y vco x Fc Fs vco x Fmin Fmax Fs I y vco x Fc Fs creates a signal that oscillates at a frequency determined by thereal input vector or array x with sampling frequency Fs Fc isthe carrier or reference frequency when x is 0 y isan Fc Hz cosine with amplitude 1 sampled at Fs Hz x ranges from 1 to 1 where 1 corresponds to a 0 frequency output O tofc and 1to2 Ffc y isthesamesizeasx y vco x Fmin Fmax Fs scales the frequency modulation range so that l and 1 values of x yield oscillations of F mi n HZ and F max Hz respectively For best results F mi n and F mx should bein therangeO toFs 2 By default Fs is LandfFc iSFs 4 Ifx isa matrix vc o produ
126. respectively at the frequency w k and n is the number of frequency points the length ofh and w This algorithm is based on Levi 1 Several variants have been suggested in the literature where the weighting function wt gives less attention to high frequencies The superior output error algorithm uses the damped Gauss N ewton method for iterative search 2 with the output of the first algorithm as the initial estimate This solves the direct problem of minimizing the weighted sum of the squared error between the actual and the desired frequency response points 2 Bw k h k Y A w k n min X we k ba KZI 6 188 invfreqs See Also References freqs Frequency response of analog filters freqz Frequency response of digital filters invfreqz Discrete time filter identification from frequency data prony Prony s method for time domain IHR filter design 1 Levi E C Complex Curve Fitting IRE Trans on Automatic Control Vol AC 4 1959 Pgs 37 44 2 Dennis J E r and R B Schnabel Numerical Methods for Unconstrained Optimization and Nonlinear Equations Englewood Cliffs NJ Prentice Hall 1983 6 189 invfreqz Purpose Syntax Description 6 190 Discrete time filter identification from frequency data b a invfregz h w nb na b a invfreqz h w nb na wt b a invfregz h w nb na wt iter b a invfregz h w nb na wt iter tol b
127. runs from Ws to 1 the Nyquist frequency cheblord also returns Wn the Chebyshev type cutoff frequency that allowscheby1 to achieve the given specifications Usecheblord for lowpass highpass bandpass and bandstop filters For highpass filters Wo gt Ws For bandpass and bandstop filters Wp and Ws are two element vectors that specify the corner frequencies at both edges of the filter lower frequency edge first For the band filters cheblord returns Wn as a two element row vector for input tocheby1l If filter specifications call for a bandpass or bandstop filter with unequal ripple in each of the passbands or stopbands design the filter as separate lowpass and highpass sections and cascade the two filters together cheblord Analog Domain n Wn cheblord Wp Ws Rp Rs s findstheminimumorder n and cutoff frequencies Wn for an analog filter In this casethe frequenciesin Wp and Ws are in radians per second and may be greater than 1 Usecheblord for lowpass highpass bandpass and bandstop filters as described under Digital Examples Domain For data sampled at 1000 Hz design a lowpass filter with less than 3 dB of attenuation from 0to 100 Hz and attenuation at least 15 dB from 150 Hz tothe Nyquist frequency Wp 100 500 Rp 3 Rs n Wn Ws 15 n Wn 0 2000 b a freqz b a 512 1000 150 500 cheblord Wp Ws Rp Rs chebyl n Rp Wn Magnitude Response d
128. s C sI A B D For single input single output systems this form is given by _ bls _ b 1 s b 2 s7O7 b nb 1 als as a 4 a na 1 H s Given the coefficients of a Laplace transform transfer function resi due determines the partial fraction expansion of the system See the description of residue in the MATLAB Language Reference Manual for details The factored zero pole gain formis 2s _ k s z 1 s z 2 s z n H s p s s p s p 2 s p n As in the discrete time case MATLAB stores polynomial coefficients in row vectors in descending powers of s MATLAB stores polynomial roots or zeros and poles in column vectors Linear System Transformations The Signal Processing Toolbox provides a number of functions that convert between the various linear system models see the reference description in Chapter 6 for a complete description of each You can use the following chart to find an appropriate transfer function find the row of the model to convert from on the left side of the chart and the column of the model to convert to on the top of the chart and read the function name s at the intersection of the row and column 1 41 1 Signal Processing Basics 1 42 Zero Second Transfer State pole Partial Lattice order Convolution function space gain fraction filter sections matrix Transfer tf2ss tf2zp residuez tf2latc convmt x function roots res
129. sides of the passband Wp 100 200 500 Ws 50 250 500 Rp 3 Rs 30 n Wn buttord Wp Ws Rp Rs b a butter n Wn freqz b a 128 1000 fs i o T Magnitude Response dB n i O O T w So oS L L ik i L i L L 100 150 200 250 300 350 400 450 500 Frequency Hertz o a fo 500 T T T Phase degrees 1000 1 L L L L L L L L 0 50 100 150 200 250 300 350 400 450 500 Frequency Hertz Algorithm but t or d s order prediction formula is described in 1 It operates in the analog domain for both analog and digital cases For the digital case it converts the frequency parameters to the s domain before estimating the order and natural frequency then converts back to the z domain buttord initially develops a lowpass filter prototype by transforming the passband frequencies of the desired filter to 1 rad sec for low and highpass filters and to 1 and 1 rad sec for bandpass and bandstop filters It then computes the minimum order required for a lowpass filter to meet the stopband specification 6 36 buttord See Also butter Butterworth analog and digital filter design cheblord Chebyshev type filter order selection cheb2ord Chebyshev type II filter order selection ellipord Elliptic filter order selection kaiserord Estimate parameters for an FIR filter design with Kaiser window References 1 Rabiner L R and B Gold Theory and Application of Dig
130. size specified by shape e same returns the central part of the convolution that is the same size as X default e full returns the full two dimensional convolution size Y gt size X e valid returns only those parts of the convolution that are computed without the zero padded edges si ze Y lt size X filter2 is part of the MATLAB environment It usesconv2 tocomputethe full two dimensional convolution of the FIR filter with the input matrix By default f i ter 2 extracts and returns the central part of the convolution that is the same size as the input matrix Use thes hape parameter to specify an alternate part of the convolution for return conv2 Two dimensional convolution filter Filter data with a recursive IIR or nonrecursive FIR filter 6 133 filtfilt Purpose Syntax Description Algorithm See Also References 6 134 Zero phase digital filtering y filtfilt b a x y filtfilt b a x performs zero phase digital filtering by processing the input data in both the forward and reverse directions See problem 5 39 in 1 After filtering in the forward direction it reverses the filtered sequence and runs it back through the filter The resulting sequence has precisely zero phase distortion and doublethe filter order fi tfilt minimizes start up and ending transients by matching initial conditions and works for both real and complex inputs Note that filtfilt should not be used with differe
131. that meets the same requirements is given by n Wn ellipord 1000 2000 5000 500 2500 5000 1 60 n Wn 0 2000 0 4000 b a ellip n 1 60 Wn These functions also work with the other standard band configurations as well as for analog filters see Chapter 6 for details Comparison of Classical IIR Filter Types The toolbox provides five different types of classical IIR filters each optimal in some way This section shows the basic analog prototype form for each and summarizes major characteristics Butterworth Filter The Butterworth filter provides the best Taylor Series approximation to the ideal lowpass filter response at Q 0 and Q for any order N the magnitude squared response has 2N 1 zero derivatives at these locations maximally flat IIR Filter Design at Q 0 and Q Response is monotonic overall decreasing smoothly from Q 0t0Q e H jQ sqrt 1 2 at Q 1 1 Magnitude o D T P T 10 Frequency rad sec Chebyshev Type Filter The Chebyshev type filter minimizes the absolute difference between the ideal and actual frequency response over the entire passband by incorporating an equal ripple of Rp dB in the passband Stopband response is maximally flat The transition from passband to stopband is more rapid than for the Butterworth filter H jQ 10 R at Q 1 1 o 6f Magnitude nea PEE L 0 1 Frequency rad sec
132. that two poles are the same if the magnitude of their difference is smaller than 0 1 percent of either of the poles magnitudes Partial fraction expansion arises in signal processing as one method of finding theinverse z transform of a transfer function F or example the partial fraction expansion of 44877 A z 1462714827 1 35 1 Signal Processing Basics 1 36 b 4 8 a 1 6 8 r p k residuez b a r 12 8 p 4 2 k corresponding to 12 8 A z F FT 1 4z 1 2z Tofind theinverse z transform of H z find the sum of the inverse z transforms of the two addends of H z giving the causal impulse response h n 12 4 8 2 n 0 1 2 To verify this in MATLAB imp 10 0 0 0 resptf filter b a imp resptf 4 32 160 704 2944 respres filter r 1 1 p 1 imp filter r 2 1 p 2 imp respres 4 32 160 704 2944 Linear System M odels Second Order Sections SO S Any transfer function H z has a second order sections representation L 1 2 l l bog bigz bagz H z H z Ok Ik I 2k 7 kel A0k T Alk akz k 1 where L is the number of second order sections that describe the system MATLAB represents the second order section form of a discrete time system as an L by 6 array sos Each row ofsos contains a single second order section where the row elements are the three numerator and three denominato
133. the discrete time F ourier transform at equally spaced frequencies around the unit circle the two functions implement the relationships N 1 X k 1 X x n we n 0 N 1 x n 1 ZY xa pwr k 0 In these equations the series subscripts begin with 1 instead of 0 because of MATLAB s vector indexing scheme and 2 Wn e N NOTE MATLAB uses a negativej for thef ft function This is an engineering convention physics and pure mathematics typically use a positive j f ft with a single input argument x computes the DFT of the input vector or matrix Ifx isa vector f f t computes the DFT of the vector ifx is a rectangular array f ft computes the DFT of each array column 1 43 1 Signal Processing Basics 1 44 For example create a time vector and signal t 0 1 99 1 time vector x sin 2 pi 15 t sin 2 pi 40 t signal The DFT of the signal and the magnitude and phase of the transformed sequence are then y fft x Compute DFT of x m abs y p unwrap angle y mag and phase To plot the magnitude and phase f O length y 1 99 length y frequency vector pl ot f m set gca XTick 15 40 60 85 pl ot f p 180 pi set gca XTick 15 40 60 85 15 40 60 8 50 0 40 500 30 20 1000 10 0 ba 1500 15 40 60 85 A second argument tof f t specifies a number of points n for the transform representing DFT length y fft x n In t
134. the frequencies dividing by a factor such as half the highest frequency present in w soas to obtain well conditioned values ofa and b This corresponds to a rescaling of time Convert a simple transfer function to frequency response data and then back to the original filter coefficients a 123 21 4 b 1 2 3 2 3 h w fregs b a 64 bb aa invfreqgs h w 4 5 bb 1 0000 2 0000 3 0000 2 0000 3 0000 aa 1 0000 2 0000 3 0000 2 0000 1 0000 4 0000 6 187 invfreqs Notice that bb andaa are equivalent tob anda respectively However aa has poles in the left half plane and thus the system is unstable Usei nvf reqs s iterative algorithm to find a stable approximation to the system bbb aaa invfreqs h w 4 5 30 bbb 0 6816 2 1015 2 6694 0 9113 0 1218 aaa 1 0000 3 4676 7 4060 6 2102 2 5413 0 0001 Suppose you have two vectors mag and phase that contain magnitude and phase data gathered in a laboratory and a third vector w of frequencies You can convert the data into a continuous time transfer function usingi nvf reqs b a invfregqs mag exp j phase w 2 3 Algorithm By default i nvf reqs uses an equation error method to identify the best model from the data This finds b anda in n min we dlh k AQw k Bow ba KZ by creating a system of linear equations and solving them with MATLAB s operator Here A w k and B w k are the Fourier transforms of the polynomials a andb
135. the frequency response at both f and f 4 17 4 Special Topics 4 18 By default i nvf reqz uses an equation error method to identify the best model from the data This finds b and a in n min J OOA Bordo k 1 by creating a system of linear equations and solving them with MATLAB s operator H ere A w k and B w k are the Fourier transforms of the polynomials a andb respectively at the frequency w k and n is the number of frequency points the length ofh and w wt k weights the error relative tothe error at different frequencies The syntax invfreqz h w nb na wt includes a weighting vector In this mode the filter resulting fromi nvfreqz is not guaranteed to be stable i nvfreqz provides a superior output error algorithm that solves the direct problem of minimizing the weighted sum of the squared error between the actual frequency response points and the desired response B w k k h k Pi PO Crs To use this algorithm specify a parameter for the iteration count after the weight vector parameter wt ones size w create unity weighting vector bbb aaa invfregz h w 3 3 wt 30 30 iterations bbb 0 0464 0 1829 0 2572 0 1549 aaa 1 0000 0 8664 0 6630 0 1614 Parametric M odeling The resulting filter is always stable Graphically compare the results of the first and second algorithms to the original Butterworth filter T Original
136. the vertical and horizontal distance between features in a signal or spectrum the dimensions of peaks and valleys and point and slope information In the following discussion the Signal Browser is shown The ruler controls include the Selection controls at the top right of the window and the buttons and edit boxes in the Rulers panel The controls in the Filter Viewer and Spectrum Viewer work the same way In the Filter Viewer the rulers only appear on one subplot at a time You can choose which subplot the rulers appear on by selecting the subplot from the pop up menu at the top of the Rulers panel If a subplot is not currently visible when you select its name from the pop up menu the Filter Viewer creates the subplot and places the rulers in it Using SPTool Find ruler button Selection pop up menu Selection display E Signal Browser File Options Window Color button Ruler control buttons 2 0 35953 y2 0 38843 dy 0 17983284 Rulers panel PA Display peaks and valleys Peaks pkg buttons Save Rulers Save Rulers button Selecting a line to measure When thereis only onesignal displayed the displayed signal is automatically selected and is measured when you use the rulers When there is more than one signal displayed only one signal line may be selected and measured at a time When a signal line is selected you can use the ruler controls Vertical Horizontal Track or Slope
137. then click on anything in the Spectrum Viewer including menu items to find out what it is and how to use it 5 91 5 Interactive Tools 5 92 Main Axes Display Area The Spectra list in SPT ool shows all spectra in the current SPTool session One or more spectra may be selected The spectral data of all selected spectra are displayed graphically in the main axes display area of the Spectrum Viewer NOTE If aspectrum is not displayed or if it is displayed with the wrong signal information press Apply to recompute the spectral data When there is only one spectrum displayed its properties are displayed in the Parameters pane and its measurements are displayed in the Rulers panel When more than one spectrum is displayed select the line you want to focus on When a spectrum is selected you can use the ruler controls on the selected line see Making Signal Measurements on page 5 37 and you can modify its parameters see below The label of the sel ected spectrum line is displayed in the Selection pop up menu There are two ways to select a spectrum line e Click on the Selection pop up menu and drag to select the line to measure or e Movethe mouse pointer over any point in theline you want to select and click on it See Selecting a line to measure on page 5 33 for details Click and Drag Panning You can use the mouse to pan around the main axes display Click on a line in the main axes hold down
138. to a selected signal using the Apply button in SPTool see Applying a Filter on page 5 19 NOTE For information on using filter design functions from the command line or from M files see Chapter 2 5 55 5 Interactive Tools 5 56 Opening the Filter Designer You can open or activate the F ilter Designer from SPTool by pressing the New Design or Edit Design buttons e Tocreatea filter press New Design in SPTool A default filter is generated and displayed in the Filter Designer You can view the filter in a variety of ways in the Filter Viewer and modify it in the Filter Designer e Toedit a filter select it in SPTool and press Edit Design Y ou can modify the filter in a variety of ways in the Filter Designer See Designing a Filter on page 5 18 for complete details Basic Filter Designer Functions The Filter Designer has the following components e A pop up menu for selecting different filter designs e A magnitude plot display area for viewing filters graphically e A Specifications panel for viewing and modifying the design parameters of the current filter e A Measurements panel for viewing the characteristics of the current filter e Specification lines for graphically adjusting the response parameters of a filter e Measurement lines for measuring the response parameters of a filter e Zoom controls for getting a closer look at the magnitude response features The following sections describe the di
139. to polynomials with coefficients in row vectors b anda Ther esi due function in the MATLAB environment is very similar tor esi duez It computes the partial fraction expansion of continuous time systems in the Laplace domain see reference 1 rather than discrete time systems in the z domain as does resi duez resi duez applies standard MATLAB functions and partial fraction techniques tofindr p andk fromb anda It finds 1 Thedirect termsa usingdeconv polynomial long division when length b gt length a 1 2 Thepolesusingp roots a mpol es finds repeated poles and reorders the poles according to their multiplicities 3 Theresidue for each nonrepeating pole p by multiplying b z a z by 1 1 p z and evaluating the resulting rational function at z p 4 Theresidues for the repeated poles by solving 2 r2 h S1 rl for r2 using h is the impulse response of the reduced b z a z S1 isa matrix whose columns are impulse responses of the first order systems made up of the nonrepeating roots andr 1 is a column containing the residues for the nonrepeating roots Each column of matrix 2 isan impulse response For each root p of multiplicity s 2 contains s columns representing the impulse responses of each of the following systems 1 pjz a p a p The vector h and matrices S1 and S2 haven xtra rows wheren is the total number of roots and the internal parameter xtra set to 1 by default determines the degree of over
140. tord selects the minimum order digital or analog Butterworth filter required to meet a set of filter design specifications Wp Passband corner frequency Wp the cutoff frequency has a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Ws Stopband corner frequency Ws is in the same units as Wp it has a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Rp Passband ripple in decibels This value is the maximum permissible passband loss in decibels The passband is 0 lt w lt Wp Rs Stopband attenuation in decibels This value is the number of decibels the stopband is down from the passband The stopband isWs lt w lt 1 Digital Domain n Wn buttord Wp Ws Rp Rs returns the order n of the lowest order 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 passband runs from 0 to Wo and the stopband runs from Ws to 1 the Nyquist frequency buttord also returns Wn the Butterworth cutoff frequency that allowsbut ter toachievethe given specifications the 3 dB frequency Usebuttord for highpass bandpass and bandstop filters F or highpass filters Wp is greater than Ws For bandpass and bandstop filters Wp and Ws are two element vectors that specify the corner frequencies at both edges of the filter lower frequency edge first For the band filte
141. track rulers arein use the measurements displayed in the Rulers panel are x1 the position of ruler 1 on the x axis y1 the position of 5 39 5 Interactive Tools 5 40 ruler 1 on the y axis x2 the position of ruler 2 on the x axis y2 the position of ruler 2 on the y axis dx the value of x2 x1 and dy the value of y2 y1 Click Track to put the rulers in track mode You can change the track marker in the Rulers preferences panel see Ruler Settings on page 5 22 In track mode you may change the x values of the rulers that is their horizontal position As the x1 and x2 values change the values of y1 y2 dx and dy change automatically Change the x1 and x2 values by either e Dragging the rulers to the left and the right with the mouse or e Entering their values in the x1 and x2 edit boxes in the Rulers panel Ruler Controls Slope There are two vertical rulers called ruler 1 and ruler 2 with the slope line passing through the y axis intersections of the two vertical rulers and the signal The rulers also track the signal with markers on each ruler that shows the y values of the signal at the x values of the rulers Theline connecting x1 y1 and x2 y2 is included in the main plot so you can approximate derivatives and slopes of the signal When slope rulers arein use the measurements displayed in the Rulers panel are x1 the position of ruler 1 on the x axis y1 the position of ruler 1 on th
142. unit cirde 6 236 unit impulse function 1 7 unit ramp function 1 7 unit sample multichannel representation 1 7 unit step function 1 7 unwrap 1 27 6 3 6317 Update button 5 20 5 88 upfirdn 1 19 4 22 6 9 6 318 V Valleys button Signal Browser 5 36 variance of correlation sequence estimate 3 4 of power spectrum estimate 3 8 vco 4 28 4 30 6 9 6 322 vector data 1 4 display in Signal Browser 5 48 for filter coefficients 1 16 1 32 frequency 2 24 6 141 6 144 6 256 6 333 in SPTool 5 15 indexing xvii 1 15 magnitude 2 24 6 141 6 144 6 333 time 1 6 weighting 2 24 6 151 6 256 Vertical button for rulers 5 35 5 37 View button 5 17 5 20 voltage controlled oscillator 4 30 6 322 Ww waveform aperiodic 1 9 chirp chirp example 1 9 from sinusoids 1 6 generating with di ric function 1 12 generating with pul st ran 1 10 generating with si nc function 1 10 linear swept frequency cosine See chirp periodic 1 8 sawtooth 1 8 6 274 example 1 8 sinusoidal pulse Gaussian modul ated 1 9 square 1 8 6 293 triangle 6 274 1 25 Index Welch s method 3 6 bias 3 11 compared to the Burg method 3 22 compared to the MTM method 3 19 compared to the Yule Walker AR method 3 20 for cross spectral density estimation 3 13 6 87 for nonparametric system identification 3 14 for power spectral density estimation 3 5 3 10 6 68 6 242 in Spectrum Viewer 5 97 normalization 3 11 white noise 1 6 window applied to perio
143. vectors The generated matrix represents a digital filter that you can apply to any 1 39 1 Signal Processing Basics 1 40 vector of appropriate length the inner dimension of the operands must agree to compute the inner product The convolution matrix for a vector b representing the numerator coefficients for a digital filter is b 1 2 3 x randn 3 1 C convmtx b 3 G2 DoD OW NP Fk ouwrne o 0 0 1 2 3 Two ways to convolveb with x are yl Ctx y2 conv b x Type this example into MATLAB the results for y1 and y2 are equal Continuous Time System Models The continuous time system models are representational schemes for analog filters Many of the discrete time system models described earlier are also appropriate for the representation of continuous time systems e State space form e Partial fraction expansion e Transfer function e Zero pole gain form It is possible to represent any system of linear time invariant differential equations as a set of first order differential equations In matrix or state space form you can express the equations as x Ax Bu y Cx Du Linear System M odels whereu is a vector of nu inputs xis an nx element state vector and y is a vector of ny outputs In MATLAB stored B C andD in separate rectangular arrays An equivalent representation of the state space system is the Laplace transform transfer function description Y s H s U s where H
144. vectorsz andp and the gain in the scalar k To obtain state space form use four output arguments A B C D ellip n Rp Rs Wn s or A B C D ellip n Rp Rs Wn ftype s whereda B C andD are x Ax Bu y Cx Du and u is the input x is the state vector and y is the output For data sampled at 1000 Hz design a sixth order lowpass elliptic filter with a cutoff frequency of 300 Hz 3 dB of ripple in the passband and 50 dB of attenuation in the stopband b a ellip 6 3 50 300 500 ellip The filter s frequency response is freqz b a 512 1000 n 6 Lowpass Elliptic Filter 0 7 r SS 20 60F Magnitude Response dB a L L L 1 L L L L L 1 0 50 100 150 200 250 300 350 400 450 500 Frequency Hertz 200 T T Phase degrees D oO T f L 400 d S i 1 1 if L L i i 6005 50 100 150 200 250 300 350 400 450 500 Frequency Hertz 6 113 ellip Design a 20th order bandpass ellipticfilter with a passband from 100 to 200 Hz and plot its impulse response n 10 Rp 0 5 Rs 20 100 200 500 b a ellip n Rp Rs Wn y t impz b a 101 stem t y Impulse Response of n 10 Elliptic Filter 0 2 T T T T T 0 15 0 1F T Lg 0 j all Py ii aan ca eee 0 05f 0 1F 0 15 2 1 0 20 30 40 50 60 70 80 90 100 Limitations For high order filters the state space form is the most numerically accurate
145. y ifft x n isthen point inverseFFT Ifthelength of x islessthann i fft pads x with trailing zeros to length n If thelength of x is greater than n if ft truncates the sequence x When x is an array i f ft adjusts the length of the columns in the same manner ifft is part of the standard MATLAB environment ifft isanM file Thealgorithm for i f ft isthe same as that for f f t except for a sign changeandascalefactor ofn engt h x The execution timeis fastest when n is a power of two and slowest when n is a large prime fft One dimensional fast Fourier transform fft2 Two dimensional fast Fourier transform fftshift Rearrange the outputs of fft andfft2 ifft2 Two dimensional inverse fast Fourier transform 6 175 ifft2 Purpose Syntax Description Algorithm See Also 6 176 Two dimensional inverse fast Fourier transform Y if ft2 X Y ifft2 X m n Y ifft2 X returns the two dimensional inverse fast Fourier transform FFT of the array x If X is a vector Y has the same orientation as X Y ifft2 X m n truncates or zero pads X if necessary to create an m by n array before performing the inverse FFT The result Y is also m by n For anyX ifft2 fft2 X equals X to within roundoff error If X is real ifft2 fft2 X may have small imaginary parts ifft is part of the standard MATLAB environment The algorithm for i f f t 2 isthe same as that for f f t 2 except for a sign change and
146. you can export the filter information to the workspace or to disk using Export from the File menu in SPTool The filter information is stored in a structure that you can access to retrieve the coefficients and design parameters of the filter you created The filter structure also contains a number of fields that are used internally by SPTool Tosee the fields of the filter structure first export a filter to the workspace 1 Create a new filter by pressing New Design in SPTool The new filter is calledfilt1 2 Select Export from the File menu 3 Inthe Export from SPTool dialog box select f i t1 and press the Export to Workspace button 4 Typewho at the MATLAB command line to look at the variables in the workspace The variable called fi t1 is the filter structure you exported from SPT ool 5 Atthecommand linetypefi t1 tolist the fields of the filter structure Thetf fs andspecs fields of the filter structure contain the information that describes the filter These fields are discussed below The other fields in the structure are used internally by SPTool and are subject to change in future releases 5 69 5 Interactive Tools 5 70 tf Thetf fieldisastructure containing thetransfer function representation of the filter e tf num contains the numerator coefficients and e tf den contains the denominator coefficients both in descending powers of z B z _ b 1 b 2 z7 b nb z H z A Z a 1
147. 0 100 110 120 130 140 Algorithm czt uses the next power of 2 length FFT to perform a fast convolution when computing the z transform on a specified chirp contour 1 czt can be significantly faster than f ft for large prime length sequences Diagnostics Ifm w Ora is not a scalar czt gives the following error message Inputs M W and A must be scalars See Also fft One dimensional fast Fourier transform freqz Frequency response of digital filters 6 90 czt References 1 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 393 399 6 91 dct Purpose Syntax Description 6 92 Discrete cosine transform DCT y dct x y dct x n y dct x returns the unitary discrete cosine transform of x N m 2n 1 K 1 y k Le ai k 1 N n where 1 n 1 wn 4 N A 2 lt n lt N N is the length of x and x andy are the same size If x is a matrix dct transforms its columns The series is indexed from n 1 and k 1 instead of the usual n 0 and k 0 because MATLAB vectors run from 1 toN instead of from Oto N 1 y dct x n pads or truncates x to length n before transforming The DCT is closely related to the discrete F ourier transform You can often reconstruct a sequence very accurately from only a few DCT coefficients a useful property for applications requiring data reduction dct Example
148. 1st Estimate 2nd Estimate 0 i 1 i L i 1 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 To verify the superiority of the fit numerically sum abs h freqz bb aa w 2 total error algorithm 1 ans 0 0200 Sum abs h freqz bbb aaa w 2 total error algorithm 2 ans 0 0096 4 19 4 Special Topics Resampling The toolbox provides a number of functions that resample a signal at a higher or lower rate Operation Function Resample at new rate resample Decimation deci mate Interpolation interp Apply FIR filter with resampling upfirdn Cubic spline interpolation spline Other 1 D interpolation interpl Ther es amp e function changes the sampling rate for a sequence to any rate that is a ratio of two integers The basic syntax for resample is y resampl e x p q where the function resamples the sequence x at p q times the original sampling rate The length of the result y isp q times the length of x One resampling application is the conversion of digitized audio signals from one sampling rate to another such as from 48 kHz the Digital Audio Tape standard to 44 1 kHz the Compact Disc standard In the next example the sampling rates are different but the idea is the same 4 20 Resampling The example file contains a length 4001 vector of speech sampled at 7418 Hz clear load mtl b whos Name Size Bytes Class Fs 1x1 8 double array mt b 4001x1 32008 double array
149. 4 0 77 J 0 6F 0 5F 0 4 4 0 37 4 0 27 J 0 17 4 0 i f i i 0 0 2 0 4 0 6 0 8 1 This example generates a periodic Gaussian pulse signal at 10 kHz with 50 bandwidth The pulse repetition frequency is 1 kHz sample rateis 50 kHz and 6 245 pulstran pulse train length is 10 msec The repetition amplitude should attenuate by 0 8 each time t 0 1 50E3 10e 3 d 0 1 1E3 10e 3 0 8 0 10 y pulstran t d gauspuls 10e3 0 5 plot t y 1 0 8 0 6 0 4 0 2 HH 0 2 0 4 0 6 J PS 0 0 002 0 004 0 006 0 008 0 01 6 246 pulstran See Also This example generates a train of 10 Hamming windows p hamming 32 t 0 320 d 0 9 32 y pulstran t d p p lot t y 1 0 9 0 8 0 7 0 6 0 5 0 4 0 3 0 2 oal 50 100 150 200 250 300 350 chirp Swept frequency cosine generator cos Cosine of vector matrix elements see the online MATLAB Function Reference diric Dirichlet or periodic sinc function gauspuls Gaussian modulated sinusoidal pulse generator rectpuls Sampled aperiodic rectangle generator sawtooth Sawtooth or triangle wave generator sin Sine of vector matrix elements See the online MATLAB Function Reference sinc Sinc or sin zt rt function square Square wave gen
150. 512 2 W3 f fregqz w3 sum w3 1 512 2 plot f 20 logl0 abs W1 W2 W3 Three Kaiser Window Responses T B o me B T D oO To or N T E 6 120 g zZ Fe 140 4 beta 1 beta 2 160 beta 3 J 180 1 L L 1 L i L L L 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized Frequency Nyquist 1 45 4 Special Topics As increases the sidelobe height decreases and the mainlobe width increases To see how the sidelobe height stays the same for a fixed B parameter as the length is varied try wl kaiser 50 4 w2 kaiser 20 4 w3 kaiser 101 4 W1 f fregqz wl sum wl 1 512 2 W2 f freqz w2 sum w2 1 512 2 W3 f freqz w3 sum w3 1 512 2 plot f 20 1og10 abs Wl W2 W3 Three Kaiser Window Responses Beta Fixed 0 amp T T T T T T T T T N length 50 a AS length 20 length 101 20 oa i X 40t hh pees J v A R ke 3 E yl 5 I Z 604 4 MARIN t I I t T l l 807 Z 100 J 120 L L L i L L i L 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized Frequency Nyquist 1 4 6 W indows Kaiser Windows in FIR Design There are two design formulas that can help you design FIR filters to meet a set of filter specifications using a Kaiser window To achieve a sidelobe height of a dB thebet a parameter is 0 1102 a 8 7 a gt
151. 6 109 6 244 6 254 6 306 6 316 pwm 4 29 pyulear 3 6 3 20 4 11 6 7 6 248 example 3 20 qam 4 29 quadrature amplitude demodulation 6 99 quadrature amplitude modulation 4 29 6 219 quantization noise 6 337 R radar applications 4 26 radix 2 algorithm 1 45 raised cosine filter design 6 155 randn XiV random number generation xiv Range pop up menu Filter Viewer 5 77 rc2poly 6 3 6252 rceps 4 23 4 24 6 9 6 253 real cepstrum 6 253 defined 4 24 reconstructing signal minimum phase 4 25 rectangular window 2 19 4 2 6 27 rectpuls 6 2 6254 recursive filter SeelIR filter references 1 46 3 26 4 39 reflection coefficients 1 37 1 39 6 234 6 252 remez 2 17 2 22 6 5 6 255 accessing from Filter Designer 5 55 5 63 5 65 compared tof irls 2 23 filter characteristics 6 260 for differentiator design 2 26 Index for Hilbert transformer design 2 25 order estimation 6 263 weight vector 2 24 Remez exchange algorithm 2 22 6 255 remezord 2 17 6 5 6 263 accessing from Filter Designer 5 65 resample 6 9 6 267 resampling 4 20 6 267 in FIR filtering 1 19 See also decimation interpolation residue 1 41 1 42 residue form See partial fraction form residuez 1 42 6 3 6 271 Revert panel 5 30 ripple passband 5 62 roots of Bessel filter 6 15 polynomial 1 33 roots 1 33 1 42 ruler color 5 22 Ruler Color edit box in Preferences dialog box 5 22 Ruler Marker pop up menu in Preferences dialog box 5 22 ruler markers 5 22 5
152. 6 218 See also modulation demodulation voltage controlled oscillation Compact Disc standard 4 20 complex cepstrum defined 4 23 complex conjugate 6 76 Complex Display mode 5 45 complex envelope 4 37 complex numbers grouping by conjugate 6 76 complex signals in Signal Browser 5 45 computation parameters in Spectrum Viewer 5 93 5 94 Conf I nt check box 5 98 confidence interval for cross spectral density 3 14 for power spectral density 3 14 5 98 setting in Spectrum Viewer 5 98 conservation of total power using pmt m 3 19 context sensitive help in SPT ool 5 8 continuous signal See signal continuous time filter See analog filter control systems 1 35 Control Systems Toolbox 1 35 6 181 conv 1 14 1 20 6 2 6 69 conv2 1 14 6 2 6 70 convmtx 1 39 1 42 6 3 6 72 convolution and cross correlation 3 3 and filtering 1 14 6 133 convolution matrix 1 39 6 72 defined 6 69 example 1 14 two dimensional 6 70 obtaining subsection 6 70 convolution matrix 1 42 6 72 defined 1 39 example 6 72 corrcoef 6 6 6 74 correlation 3 2 coefficient matrix 6 74 See also autocorrelation cross correlation cosine window 4 4 cov 6 6 6 75 covariance 3 2 matrix 6 75 See also autocovariance cross covariance cpl xpair 6 8 6 76 Create button in Spectra panel 5 19 5 88 cremez 2 17 6 5 6 77 cross spectral density 3 13 6 84 confidence interval 3 14 defined 3 5 cross correlation 6 324 biased 3 3 multiple channels 3 4 normalization 3 4 two
153. 9 1 Normalized frequency Nyquist 1 500 T 3 Ob B amp 500 E x 1000 1 1 fi fi i fi i fi 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 The lower band edge is at 0 1 Hz as expected Notice however that the upper band edge is slightly less than 0 5 Hz although in the analog domain it was exactly 0 5 Hz This illustrates the nonlinear nature of the bilinear transformation To counteract this nonlinearity it is necessary to create analog domain filters with prewarped band edges which map tothe correct locations 2 43 2 Filter Design 2 44 upon bilinear transformation Here the prewarped frequencies ul and u2 generate Bw and Wo for the p2bp function Fs 2 sampling frequency Hertz ul 2 Fs tan 1 2 pi Fs 2 lower band edge radians second u2 2 Fs tan 5 2 pi Fs 2 upper band edge radians second Bw u2 ul bandwidth Wo sqrt ul u2 center frequency At Bt Ct Dt p2bp A B C D Wo Bw A digital bandpass filter with correct band edges 0 1 and 0 5 times the N yquist frequency is Ad Bd Cd Dd bilinear At Bt Ct Dt Fs The example bandpass filters from the last two sections could also be created in one statement using the complete IIR design function cheby1 For instance an analog version of the example Chebyshev filter is b a chebyl 5 3 0 1 0 5 2 pi s Note that the band edges are in radians second for
154. B For cheby1 the cutoff frequency Wn is a number between 0 and 1 where 1 corresponds to half the sampling frequency the N yquist frequency Smaller values of passband ripple Rp lead to wider transition widths shallower rolloff characteristics If Wn is atwo element vector Wn wl w2 cheby1l returns an order 2 n bandpass filter with passbandwl lt lt w2 6 51 cheby1 6 52 b a chebyl n Rp Wn ftype designs a highpass or bandstop filter wheref type is e high for a highpass digital filter with cutoff frequency Wn e stop for an order 2 n bandstop digital filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 With different numbers of output arguments cheby1 directly obtains other realizations of the filter To obtain zero pole gain form use three output arguments z p k chebyl n Rp Wn or z p k chebyl n Rp Wn ftype returns the zeros and poles in length n column vectors z and p and the gain in the scalar k To obtain state space form use four output arguments A B C D cheby1l n Rp Wn or A B C D chebyl n Rp Wn ftype wherea B C andD are x n 1 Ax n Bu n y n Cx n Du n and u is the input x is the state vector and y is the output Analog Domain b a chebyl n Rp Wn s designs an ordern lowpass analog Chebyshev type l filter with cutoff frequency Wn It returns the filter coefficients in length n 1 row vectors b a
155. B signal processing environment through the toolbox functions It describes the basic functions of the Signal Processing Toolbox reviewing its use in basic waveform generation filter implementation and analysis impulse and frequency response zero pole analysis linear system models and the discrete Fourier transform When you feel comfortable with the basic functions move on to Chapter 2 and Chapter 3 for a more in depth introduction to using the Signal Processing Toolbox e Chapter 2 Filter Design for a detailed explanation of using the Signal Processing Toolbox in infinite impulse response IIR and finite impulse response FIR filter design and implementation including special topics in IIR filter design e Chapter 3 Statistical Signal Processing for how to use the correlation covariance and spectral analysis tools to estimate important functions of discrete random signals Once you understand the general principles and applications of the toolbox learn how to use the interactive tools e Chapter 5 Interactive Tools for an overview of the interactive GUI environment and examples of how to use it for signal exploration filter design and implementation and spectral analysis Finally see the following chapter for a discussion of various specialized toolbox functions e Chapter 4 Special Topics for a variety of specialized functions including filter windows parametric modeling resampling cepstrum
156. Bands Constrained Minimize squared integral fircls firclsl Least error over entire frequency Squares range subject to maximum error constraints Arbitrary Arbitrary responses including cremez Response nonlinear phase and complex filters Raised Lowpass response with firrcos Cosine smooth sinusoidal transition Linear Phase Filters Except for cremez all of the FIR filter design functions design linear phase filters only The filter coefficients or taps of such filters obey either an even or odd symmetry relation Depending on this symmetry and on whether the order n of the filter is even or odd a linear phase filter stored in length n 1 vector b has certain inherent restrictions on its frequency response 2 17 2 Filter Design Response Linear Phase Filter Response H f f 1 Filter Type Order n Symmetry of Coefficients H f f O Nyquist Type Even Even Norestriction Norestriction Type Odd b k b n 2 k k 1 n 1 Norestriction H 1 0 Type III Even Odd H 0 0 H 1 0 Type lV Odd b k b n 2 k k 1 n 1 H 0 0 No restriction The phase delay and group delay of linear phase FIR filters are equal and constant over the frequency band For an order n linear phase FIR filter the group delay is n 2 and the filtered signal is simply delayed by n 2 time steps and the magnitude of its Fourier transform is scaled by the filter s magnitude response This property preserves the wave sha
157. Communications Applications The toolbox provides three functions for communications simulation Operation Function Modulation modulate Demodulation demod Voltage controlled oscillation vco Modulation varies the amplitude phase or frequency of a carrier signal with reference to a message signal The modul ate function modulates a message signal with a specified modulation method The basic syntax for the modul ate function is y modulate x Fc Fs method opt where e x is the message signal e Fc isthe carrier frequency e Fs is the sampling frequency e met hod is a flag for the desired modulation method e opt is any additional argument that the method requires Not all modulation methods require an option argument 4 28 Communications Applications The table below summarizes the modulation methods provided see Chapter 6 for complete details on each Method Description amdsb sc Oram Amplitude modulation double side band suppressed carrier amdsb tc Amplitude modulation double side band transmitted carrier ams sb Amplitude modulation single side band fm Frequency modulation pm Phase modulation ptm Pulse time modulation pwm Pulse width modulation qam Quadrature amplitude modulation If the input x is an array rather than a vector modul ate modulates each column of the array Toobtain thetime vector that modul at e uses to compute the modulated signal specify a second output paramet
158. Description Functions Analog Using the poles and zeros of Complete design functions Prototyping a Classical lowpass prototype filter in the besself butter chebyl cheby2 ellip continuous Laplace Order estimation functions domain obtain a digital filter through frequency buttord cheblord cheb2ord ellipord transformation and filter discretization Lowpass analog prototype functions besselap buttap cheblap cheb2ap ellipap Frequency transformation functions p2bp lp2bs l p2hp p2lp Filter discretization functions bilinear impinvar Direct Design Design digital filter yul ewal k directly in the discrete domain by approximating a piecewise linear magnitude response Parametric Find a digital filter that Time domain modeling functions Modeling approximates a prescribed ERA time or frequency domain ee NYSS EMG es F requency domain modeling functions invfreqs invfreqz Generalized Design lowpass maxfl at Butterworth Butterworth filters with Design more zeros than poles See the System Identification Toolbox for an extensive collection of parametric modeling tools 2 Filter Design Classical IIR Filter Design Using Analog Prototyping The principal IIR digital filter design technique this toolbox provides is based on the conversion of classical lowpass analog filters to their digital equivalents The following sections describe how to design filters and summarize the characteristics of the supported filter types
159. Example Importing Signal Data froma MAT File 5 5 Basic SPTool Functions 0 0000s cece eee 5 6 PHM en scree h ele Minn ne yt teen a G tbe 5 7 Help Menu a seek cad bene eerie st caw ee ees 5 8 Importing Signals Filters and Spectra 4 5 8 Loading Variables from the MATLAB Workspace 5 9 Loading Variables from Disk 0 000 0s eee 5 9 Importing Workspace Contents and File Contents 5 9 Working with Signals Filters and Spectra 5 14 Component Lists in SPTool 0000 e eee eee 5 15 Selecting Data Objects in SPTool 0000 eee 5 15 Editing Data Objects in SPTool 0 0 5 5 16 Viewing a Signal 00 cece eee ee 5 17 Viewing a Filter 0 0 cece eee 5 17 Designing a Filter 0 0 2 cece eee 5 18 Applying a Filter e c40 04s8 few e Ge hee eed 5 19 Creating aSpectruM 0 0 c eee 5 19 Viewing a SpectruM 0 0 cece ee 5 20 Updating a Spectrum 0 0 eee ee 5 20 vi Contents Customizing Preferences 006 Ruler SettingS 0 eect es Color Settings oise ciy ennie w ee oe bee ee oe oe ee Signal Browser SettingS 00 0c cee eee eee Spectrum Viewer SettingS 0 0c cee eee eee Filter Viewer Settings 0 0000 cece eee eee Filter Viewer Tiling Settings 0 00 0005 Filter Designer Settings 0 ccc eee eee eee Plug Ins Sett
160. Filter Designed to Specifications 10 T T T T T T 204 J 30F Magnitude dB 40 50 x 4 60 L L L L L L 1 IL L 0 100 200 300 400 500 600 700 800 900 1000 Frequency Hz Note that the filter falls slightly short of meeting the specifications Usingn 1 in the call tor emez instead of n achieves the desired amplitude characteristics 6 264 remezord Algorithm Diagnostics See Also Design a lowpass filter with a 1500 Hz passband cutoff frequency and 2000 Hz stopband cutoff frequency with a sampling frequency of 8000 Hz a maximum stopband amplitude of 0 1 and a maximum passband error ripple of 0 01 n fo ao0 w remezord 1500 2000 1 0 0 01 0 1 8000 b remez n fo ao w This is equivalent to remezord 1500 2000 1 0 0 01 0 1 8000 cell remez c c b NOTE n somecases r emezor d underestimates or overestimates the order n If the filter does not meet the specifications try a higher order such as n 1 ornt 2 Results are inaccurate if the cutoff frequencies are near 0 or the Nyquist frequency remezord uses the algorithm suggested in 1 This method is inaccurate for band edges close to either 0 or the Nyquist frequency Fs 2 If theinput parameter lengths are not consistent r emezor d gives the following error messages Requires M and DEV to be the same length Length of F must be length M 2 buttord Butterworth fil
161. Fp2 Fsi1 Fs2 Rp Rs_ Fpl Fp2 Fs Fs2 Rp Rs Chebyshev Type IIR Fs Rs Fs Rs Fsl1 Fs2 Rs Fsl1 Fs2 Rs Chebyshev Type II IIR Fp Rp Fp Rp Fpl Fp2 Rp Fpl Fp2 Rp Elliptic IIR Fs Fs Fs1 Fs2 Fs1 Fs2 5 61 5 Interactive Tools 5 62 Magnitude Plot Display Area The response of the filter selected in the Filter pop up menu is displayed graphically in the magnitude response plot area of the Filter Designer and its characteristics are shown in the Specifications and Measurements panels You can zoom in on the displayed filter in the magnitude plot see Zoom Controls on page 5 30 and you can drag the specification lines to visually redesign the displayed filter see the next section Specification Lines You can redesign a filter by manipulating the green specification lines in the magnitude plot Using the specification lines you can change the passband ripple stopband attenuation and edge frequencies of a filter Set passband ripple or stopband attenuation by clicking on a green line and dragging it up or down The Rp and Rs values displayed in the Specifications panel change as you drag If Auto Design is checked the response plot also updates as you drag the lines If Auto Design is disabled the response plot updates when you release the mouse NOTE With IIR filters you can only drag the lower passband bar and the stopband bar The upper passband bar is fixed at 0 Set edge frequencies either by cli
162. Fs defaults to 2 Hz implying a Nyquist frequency of 1 Hz You can therefore specify band edges scaled to a particular application s sampling frequency c kaiserord f a dev Fs cell iS acell array whose elements are the parameters tofir1 NOTE n some cases kai serord underestimates or overestimates the order n If the filter does not meet the specifications try a higher order such asn 1 n 2 and soon or a lower order Results are inaccurate if the cutoff frequencies are near 0 or the Nyquist frequency or if dev is large greater than 10 kai serord uses empirically derived formulas for estimating the orders of lowpass filters as well as differentiators and Hilbert transformers Estimates for multiband filters such as bandpass filters are derived from the lowpass design formulas The design formulas that underlie the Kaiser window and its application to FIR filter design are 0 1102 a 8 7 a gt 50 B 40 5842 a 21 4 0 07886 a 21 5020221 0 a lt 21 where a 20109195 is the stopband attenuation expressed in decibels recall that 6 is required The design formula is a 7 95 N 228500 where n is the filter order and Aw is the width of the smallest transition region 6 195 kaiserord Examples Design a lowpass filter with passband from 0 to 1 kHz and stopband from 1500 Hz to 4 kHz Specify passband ripple of 5 and stopband attenuation of 40 cB fsamp 8000 fcuts 1000 1500 mag
163. Grand total is 4002 elements using 32016 bytes Fs Fs 7418 To play this speech signal on a workstation that can only play sound at 8192 Hz usether at function to find integers p and q that yield the correct resampling factor p q rat 8192 Fs 0001 p 127 q 115 Sincep q Fs 8192 05 Hz the tolerance of 0 0001 is acceptable to resample the signal at very close to 8192 Hz y resample mtlb p q resample applies a lowpass filter to the input sequence to prevent aliasing during resampling It designs this filter using thef i r 1 function with a Kaiser window The syntax resample x p q l beta controls the filter s length and the beta parameter of the Kaiser window Alternatively use the function i ntfi t todesign an interpolation filter b and use it with resample x p q b 4 21 4 Special Topics 4 22 Thedeci mate andi nt erp functions dothesamething asresample withp 1 andq 1 respectively These functions provide different anti alias filtering options and they incur a slight signal delay due to filtering Thei nt erp function is significantly less efficient than ther es amp e function withg 1 The toolbox also contains a function upf i rdn that applies an FIR filter to an input sequence and outputs the filtered sequence at a different sample rate than its original rate See Multirate Filter Bank Implementation on page 1 19 and the reference description of upf i rdn in Chapter 6
164. H 1 2 H z When z 1 that is z the output reduces to x a H e 2 Given all the samples of the sequence x n a doubly filtered version of x that has zero phase distortion is possible For example a one second duration signal sampled at 100 Hz composed of two sinusoidal components at 3 Hz and 40 Hz is IESi ds Fs 100 t x sin 2 pi t 3 25 sin 2 pi t 40 O ther Functions for Filtering Now create a 10 point averaging FIR filter and filter x using bothfilter and filtfilt for comparison b ones 1 10 10 10 point averaging filter y filtfilt b 1 x non causal filtering yy filter b 1 x normal filtering nlot texety yore tye YY 125 al 0 5 X J oF J 0 5 J 1F 4 155 o1 02 03 04 05 06 07 08 09 1 Both filtered versions eliminate the 40 Hz sinusoid evident in the original solid line The plot also shows howfilter andfiltfilt differ the dashed Fil tfilt lineis in phase with the original 3 Hz sinusoid while the dotted fil ter lineis delayed by about five samples Also the amplitude of the dashed line is smaller due to the magnitude squared effects of filtfilt filtfilt reduces filter startup transients by carefully choosing initial conditions and by prepending onto the input sequence a short reflected piece of the input sequence F or best results make sure the sequence you are filtering has length at least three times the filter order and that it tapers to
165. I environment This also gives you access to the MATLAB Help Desk Context Sensitive Select Context Sensitive from the File menu for help ona specific part of SPTool When you click on Context Sensitive the mouse pointer becomes an arrow with a question mark symbol You can then click on anything in SPTool including menu items to find out what it is and how touse it Importing Signals Filters and Spectra You can import a signal filter or spectrum into SPTool from either the workspace or from a file Click Import from the File menu to open the Import window ___ Display all MATLAB workspace variables in the Workspace Contents Workspace Contents list box by clicking here or File Contents list Sauce EE Fiaa wik ape l f Dek Sires Load the contents of a file into the File Contents list by clicking here and either typing a filename in the box and pressing Tab or Enter or clicking Browse and selecting a MAT file Using SPTool Loading Variables from the MATLAB Workspace Toimport variables from the MATLAB workspace first list the workspace variables in the Workspace Contents list Then select the variables to be imported into SPToo 1 Click the From Workspace radio button The contents of the MATLAB workspace are displayed in the Workspace Contents list You can now import one or more variables from the Workspace Contents list into SPT ool See Importing Workspace Contents and File Co
166. R filter design Parks McClellan optimal FIR filter design Bandpass filter design function Bandstop filter design function Differentiator filter design function Highpass filter design function Hilbert filter design function Lowpass filter design function Multiband filter design function 1 Karam L J and J H McClellan Complex Chebyshev Approximation for FIR Filter Design IEEE Trans on Circuits and Systems II March 1995 Pgs 207 216 2 Karam L J Design of Complex Digital FIR Filters in the Chebyshev Sense Ph D Thesis Georgia Institute of Technology March 1995 3 Demjanjov V F and V N Malozemov Introduction to Minimax New York J ohn Wiley amp Sons 1974 6 83 csd Purpose Syntax Description 6 84 Estimate the cross spectral density CSD of two signals Pxy csd x y Pxy csd x y nfft Pxy f csd x y nfft Fs Pxy csd x y nfft Fs wi ndow Pxy csd x y nfft Fs window noverlap Pxy csd x y dflag Pxy Pxyc f csd x y nfft Fs window noverl ap p csd x y Pxy csd x y estimates the cross spectral density of thelengthn sequences x andy using the Welch method of spectral estimation Pxy csd x y uses the following default values enfft min 256 length x e Fs 2 e window hanning nfft e noverlap 0 nfft specifies the FFT length that csd uses This value determines the frequencies at which the cross spectrum is estimated
167. Rs Wn ftype s whereda B C andD are x Ax Bu y Cx Du and u is the input x is the state vector and y is the output For data sampled at 1000 Hz design a ninth order lowpass Chebyshev typeI filter with stopband attenuation 20 dB down from the passband and a cutoff frequency of 300 Hz b a cheby2 9 20 300 500 cheby2 The frequency response of the filter is freqz b a 512 1000 Y n 9 Chebyshev Type II Filter i T 7 T 7 T T Magnitude Response dB rb d K N e o eJ T T T pA te oN i i i i 100 150 200 250 300 350 400 450 500 Frequency Hertz 100 200 Phase degrees 300 SESI 400 0 50 n fi 100 150 200 250 300 350 400 450 500 Frequency Hertz Design a fifth order bandpass Chebyshev typell filter with passband from 100 to 200 Hz and plot the impulse response of the filter n 5 100 200 500 b a yt 0 2 r 20 cheby2 n r Wn impz b a 101 stemt y Impulse Response of n 5 Chebyshev Type II Filter T T T T T T T 0 2 0 6 59 cheby2 Limitations Algorithm See Also 6 60 For high order filters the state space form is the most numerically accurate followed by the zero pole gain form The transfer function coefficient form is the least accurate numerical problems can arise for filter orders as low as 15 cheby2 uses a five step algorithm 1 It finds the
168. Rulers 500 1000 1500 2000 2500 DEME Frequency Parameters Pa 4 he MAN i il n W Wy Example Generation of Bandlimited N oise The new spectrums signal identification information including its name its type and its sampling frequency is displayed above the Parameters panel and the spectrum s name is displayed both above the main axes display area and in the Selection pop up menu This spectrum is flat between 750 and 1250 Hz and has 75 dB less power in the stopband regions of fi t1 9 Reactivate SPTool again as in step 5 above 10 Shift click ons pect 1 andspect2 in the Spectra list to select them both 11 Click View in the Spectra panel to reactivate the Spectrum Viewer and display both spectra together EJ Spectrum Viewer BEE File Options Window Selection Signal noise RAR Rulers 5000 by 1 real tended Fs 5000 ui Parameters T ig j Track Method Weich x1 834 9609 Nfft 1024 s pE y1 0 64819 win 256 K 2 y2 2 0962 Overlap 0 A dx 830 07812 Detrending none E 4 J dy 1 448 Scaling Unbiased f a shat V M KNIN y ALA hi LAR A wS I Conf Int l 95 80 l Peaks Valleys Inherit from 90 EE Save Rulers 0 500 1000 1500 2000 2500 Frequency 5 109 5 Interactive Tools 12 Toselect one of the spectra for measuring or editing use the Selection pop up menu or click on the spectrum in the main axes display area T
169. See Special Topics in HR Filter Design on page 2 37 for detailed steps on the filter design process Complete Classical IIR Filter Design You can easily create a filter of any order with a lowpass highpass bandpass or bandstop configuration using the filter design functions Filter Type Design Function Butterworth b a butter n Wn options z p k butter n Wn options A B C D butter n Wn options Chebyshev type b a chebyl n Rp Wn options z p k chebyl n Rp Wn options A B C D chebyl n Rp Wn options Chebyshev type I b a cheby2 n Rs Wn options z p k cheby2 n Rs Wn options A B C D cheby2 n Rs Wn options Elliptic b a ellip n Rp Rs Wn opti ons z p k ellip n Rp Rs Wn options A B C D ellip n Rp Rs Wn options Bessel analog only b a besself n Wn opti ons z p k besself n Wn opti ons A B C D besself n Wn options By default each of these functions returns a lowpass filter you need only specify the desired cutoff frequency Wn in normalized frequency Nyquist frequency 1 Hz For a highpass filter append the string hi gh tothe function s parameter list For a bandpass or bandstop filter specify Wn as a two element vector containing the passband edge frequencies appending the string stop for the bandstop configuration IIR Filter Design Here are some example digital filters b a butter 5 4 lowpass Butterworth
170. Signal Processing Toolbox For Use with MATLAB Computation Visualization Programming gt i User s Guide Version 4 How to Contact The MathWorks 508 647 7000 Phone 508 647 7001 Fax The MathWorks Inc Mail 24 Prime Park Way Natick MA 01760 1500 http www mathworks com Web ftp mat hworks com Anonymous FTP server comp soft sys matlab Newsgroup support mathworks com Technical support suggest mathworks com Product enhancement suggestions bugs mathworks com Bug reports doc mathworks com Documentation error reports subscribe mathworks com Subscribing user registration service mathworks com Order status license renewals passcodes info mathworks com Sales pricing and general information Signal Processing Toolbox User s Guide COPY RIGHT 1988 1998 by The MathWorks Inc All Rights Reserved The software described in this document is furnished under a license agreement The software may be used or copied only under the terms of the license agreement No part of this manual may be photocopied or repro duced in any form without prior written consent from The MathWorks Inc U S GOVERNMENT If Licensee is acquiring the Programs on behalf of any unit or agency of the U S Government the following shall apply a For units of the Department of Defense the Government shall have only the rights specified in the license under which the commercial computer software or commercial software documentation wa
171. Specifying corr forcesx to be taken as a correlation matrix corr must appear at the end of the argument list Pxx freg a pyulear x p nfft Fs corr returns vector a of filter coefficients for the all pole filter model pyulear plots the power spectral density in the first available figure window pyulear Examples This example analyzes a sequence x n assuming that two real signals are present in the signal subspace In this case the model order must be four or larger because each real sinusoid is the sum of two complex exponentials Experience shows that taking a larger model order than the minimum seems to work better Create xx as a signal vector nn 0 199 randn seed 0 xx 0S 0 257 pi nn sin 0 2 pi nn 0 01 randn size nn PP ff aa pyulear xx 7 7th order model plot ff pi 10 log10 PP Plot the pole locations 15 i T T 3 5 6 249 pyulear Algorithm Diagnostics 6 250 The following examples usexx as a correlation matrix and a data matrix Assume that RR is a square corr matrix for example 7 by 7 RR toeplitz cos 0 1 pi 0 6 0 1 eye 7 PP ff pyulear RR 4 corr Create a matrix of 100 observations of a stochastic process xx is rectangular 7 by 100 xx reshape cos 0 257 pi 0 699 7 100 0 1 randn 7 100 PP ff pyulear xx 4 default FFT length 256 Same 7 by 100 matrix with a longer FFT
172. The frequency range cannot be negative if Scale is set to log You can also change the frequency axis display characteristics for the Filter Viewer using the Filter Viewer settings panel of the Preferences dialog in SPTool 5 77 5 Interactive Tools 5 78 Zoom Controls The available zoom controls in the Filter Viewer are Mouse Zoom and Full View You can zoom independently in each displayed subplot By default persistent zooming is disabled in the Filter Viewer You can turn persistent zooming on from the Filter Viewer settings panel of the Preferences dialog in SPTool See Zoom Controls on page 5 30 for details on using the zoom controls in the Filter Viewer Help Button To use context sensitive help click on the Help button The mouse pointer becomes an arrow with a question mark symbol Y ou can then click on anything in the Filter Viewer including menu items to find out what it is and how to use it Main Plots Area Oneor more of thesix filter response subplots may be displayed graphically in the main plots area of the Filter Viewer You can specify how the subplots are arranged by selecting Filter Viewer Tiling from the Preferences dialog in SPTool The options are 2 by 3 Grid 3 by 2 Grid Vertical 6 by 1 Grid and Horizontal 1 by 6 Grid Using the Filter Viewer Interactive Filter Analysis The following figure shows the Filter Viewer when four subplots are turned on and the 2 by 3 grid option is s
173. The window applied here is a simple rectangular or boxcar window By Parseval s theorem this is the length 51 filter that best approximates the ideal lowpass filter in the integrated least squares sense To view its frequency response H w fregz b 1 512 2 plot w abs H grid Truncated Sinc Lowpass FIR Filter Magnitude Response oO f i i f 1 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized Frequency Nyquist 1 Note the ringing and ripples in the response especially near the band edge This Gibbs effect does not vanish as the filter length increases but a 2 19 2 Filter Design nonrectangular window reduces its magnitude Multiplication by a window in the time domain causes a convolution or smoothing in the frequency domain Apply a length 51 Hamming window tothe filter b b hamming 51 H w fregz b 1 512 2 plot w abs H grid Hamming Windowed Truncated SINC LP FIR Filter 1 2 T T T T T Magnitude Response o 2 0 2 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized Frequency Nyquist 1 As you can see this greatly reduces the ringing This improvement is at the expense of transition width the windowed version takes longer to ramp from passband to stopband and optimality the windowed version does not minimize the integrated squared error The functions fir1 andfir2 are based on this windowing process Given a filter order and descript
174. This is because 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 valued n fi r1 increments it by 1 b firl n Wn window uses the window specified in column vector wi ndow for the design The vector wi ndow must ben 1 elements long If no window is specified fi r1 employs a Hamming window b firl n Wn ftype window accepts bothftype and window parameters b firl noscale turns off the default scaling The group delay of the FIR filter designed byfir1 isn 2 fir 1 uses the window method of FIR filter design 1 If w n denotes a window where 1 lt n lt N and the impulse response of the ideal filter is h n where h n is the inverse F ourier transform of the ideal frequency response then the windowed digital filter coefficients are given by b n w njh n 1 lt n lt N firl Examples Design a 48th order FIR bandpass filter with passband 0 35 lt w lt 0 65 b fir1 48 0 35 0 65 freqz b 1 512 rane meen a i T a 3 1 i 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 Magnitude Response dB o t i oa Q Q e e T 1500F Phase degrees pS is i is 2500 L L L fi L L i 0 0 1 0 2 0 3 0 4 05 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 Design a 34th order FIR highpass filter with a cutoff f
175. This is because the autocorrelation method implicitly windows the data that is it assumes that signal samples beyond the length of x are 0 4 11 4 Special Topics 4 12 To illustrate pc create a sample signal that is the impulse response of an all pole filter with additive white noise randn seed 0 x impz 1 1 0 1 0 1 0 1 0 1 10 randn 10 1 10 The coefficients for a fourth order all pole filter that models the system are a pc x 4 a 1 0000 0 0395 0 0338 0 0668 0 1264 pc first callsxcorr tofind a biased estimate of the correlation function of x and then uses the Levinson Durbin recursion implemented in the evi nson function to find the model coefficients a The Levinson Durbin recursion is a fast algorithm for solving a system of symmetric Toeplitz linear equations pc sentirealgorithm for n 4 is r xcorr x r l length x 1 remove corr at negative lags a levinson r 4 a 1 0000 0 0395 0 0338 0 0668 0 1264 You could form the linear prediction coefficients with other assumptions by passing a different correlation estimate to evi nson Such as the unbiased correlation estimate r xcorr x unbiased r l length x 1 remove corr at negative lags a levinson r 4 a 1 0000 0 0554 0 0462 0 0974 0 2115 Prony s Method ARMA Modeling Thepr ony function models a signal using a specified number of poles and zeros Given a sequence x and numerator and denom
176. Transposed Direct Form Il E r y j filter Transposed Direct Form II Output Signal sigs Type the new signal Output Signal fitfit Zero phase IIR fftfilt FFT based FIR name here Cancel OK 2 Select the filtering algorithm from the Algorithm pop up menu type the name for the new signal in the Output Signal field and dick OK Theselected filter is applied to the selected input signal and the new output signal is listed in the Signals list Creating a Spectrum Use the Create button to activate the Spectrum Viewer and generate a default spectrum of a selected signal Once you ve generated a spectrum you can view it in a variety of ways measure it and modify it in the Spectrum Viewer 1 Select one signal from the Signals list and click the Create button in the Spectra panal The Spectrum Viewer is activated and a spectrum object with default parameters is created in the Spectra panel No spectrum is computed or displayed yet The newly created spectrum has a default name of s pecn wheren is a unique sequential identifying digit Once the default spectrum 5 19 5 Interactive Tools 5 20 is created you can use it as is or edit it in the Spectrum Viewer Y ou can rename it using Name from the Edit menu 2 Usethe default parameters in the Spectrum Viewer or modify the parameters as necessary 3 Press Apply in the Spectrum Viewer to compute the spectrum This button is enabled when the spectrum has just been c
177. a invfregz h w nb na wt iter tol trace b a invfregz h w complex nb na invfreqz is theinverse operation off r eqz it finds a discrete time transfer function that corresponds to a given complex frequency response From a laboratory analysis standpoint i nvf r eqz can be used to convert magnitude and phase data into transfer functions b a invfreqz h w nb na returns the real numerator and denominator coefficients in vectors b anda of the transfer function _ B z _b 1 b 2 z b nb 1 2 H z A z a 1 a 2 z EE a na 1 whose complex frequency response is given in vector h at the frequency points specified in vector w Scalarsnb andna specify the desired orders of the numerator and denominator polynomials Frequency is specified in radians between 0 and z and the length ofh must be the same as the length of w i nvfreqz usesconj h at w to ensure the proper frequency domain symmetry for a real filter b a invfregz h w nb na wt weights the fit errors versus frequency wt is a vector of weighting factors the same length as w invfreqz h w nb na wt iter and invfreqz h w nb na wt iter tol provide a superior algorithm that guarantees stability of the resulting linear system and searches for the best fit using a numerical iterative scheme Thei t er parameter tellsi nvf r eqz toend the iteration when the solution has converged or after i ter iterations whichever comes first i nvf req
178. a Wo transforms an analog lowpass filter prototype given by polynomial coefficients into a highpass filter with cutoff frequency Wo Row vectorsb anda specify the coefficients of the numerator and denominator of the prototype in descending powers of s bls _ bs b nn s b nn 1 a s as a nd s a nd 1 Scalar Wo specifies the cutoff frequency in units of radians second The frequency transformed filter is returned in row vectors bt andat State Space Form At Bt Ct Dt p2hp A B C D Wo converts the continuous time state space lowpass filter prototype in matrices A B C D x Ax Bu y Cx Du into a highpass filter with cutoff frequency Wo The highpass filter is returned in matrices At Bt Ct Dt 6 207 Ip2hp Algorithm See Also 6 208 p2hp is a highly accurate state space formulation of the classic analog filter frequency transformation If a highpass filter is to have cutoff frequency my the standard s domain transformation is 2o P The state space version of this transformation is At Bt Ct Dt Wo inv A Wo A B C A D C A B Seel p2bp for a derivation of the bandpass version of this transformation bilinear Map variables using bilinear transformation i mpi nvar Impulse invariance method of analog to digital filter conversion p2bp Lowpass to bandpass analog filter transformation p2bs Lowpass to bandstop analog filter transformation p2lp Lowpa
179. a 2 z 14 Fa nat Dz where b is a vector containing the coefficients from thet f num field a is a vector containing the coefficients from thet f den field nb is the numerator order and na is the denominator order You can change the filter representation from the default transfer function to another form by using the tf2ss ortf2zp functions Fs TheFs field contains the sampling frequency of the filter in Hertz specs Thespecs field is a structure containing information about the filter design The first field specs current Modul e contains a string representing the design selected for the filter in the Filter Designer s Algorithm pop up menu The possible contents of thecurrent Modul e field and the corresponding designs are shown below currentModule Algorithm fdbutter Butterworth IIR fdchebyl Chebyshev Type IIR fdcheby2 Chebyshev Type ll IIR fdellip Elliptic IIR fdfirls Least Squares FIR fdkaiser Kaiser Window FIR f dremez Equiripple FIR Using the Filter Designer Interactive Filter Design Followingthespecs current Modul e field there may be up to seven additional fields with labels such asspecs fdremez specs fdfirls etc The design specifications for the most recently exported filter are contained in the field whose label matches the current Modul e string For example if thes pecs structure is currentModule fdkaiser fdremez 1x1 struct fdfirls 1x1 struct fdkaiser 1x1 struct
180. a linein the main axes hold down the mouse button and drag the mouse Click and drag panning is not enabled in mouse zoom mode Panner The panner gives a panoramic view of the signal s displayed in the main axes The panner always displays the entire signal sample When you zoom in on the main axes a patch in the panner shows the section of the plot that is currently in view in the main axes Click and drag the patch in the panner window to pan dynamically across the signal data in the main axes You can also select a line by clicking on it in the panner the selected line is highlighted in both the panner and in the main axes display area See Panner Display on page 5 51 for more details Using the Signal Browser Interactive Signal Analysis The panner is displayed by default in the Signal Browser you can turn off the panner in the Signal Browser settings panel in Preferences See Signal Browser Settings on page 5 24 Making Signal Measurements Use the rulers to make a variety of measurements on the selected signal See Making Signal Measurements on page 5 37 for details Viewing and Exploring Signals You can open or activate the Signal Browser in SPT ool by selecting oneor more signals and pressing View in the Signal panel The selected signals are loaded into the Signal Browser See Viewing a Signal on page 5 17 for details Selecting and Displaying a Signal When the Signal Browser is activa
181. abilities for a given order IIR model the last result shows that for this example s t mc b performs best followed by pr ony then pc This relative performance is typical of the modeling functions Frequency Domain Based Modeling Thei nvfreqs andi nvfreqz functions implement the inverse operations of freqs andfreqz they find an analog or digital transfer function of a specified order that matches a given complex frequency response Though the following examples demonstratei nvf r eqz the discussion also applies toi nvf reqs 4 16 Parametric M odeling Torecover the original filter coefficients from the frequency response of a simple digital filter b a butter 4 4 design Butterworth lowpass b 0 0466 0 1863 0 2795 0 1863 0 0466 a 1 0000 0 7821 0 6800 0 1827 0 0301 h w freqz b a 64 compute frequency resp bb aa invfreqgz h w 4 4 model nb 4 na 4 bb 0 0466 0 1863 0 2795 0 1863 0 0466 aa 1 0000 0 7821 0 6800 0 1827 0 0301 The vector of frequencies w has the units in radians second and the frequencies need not be equally spaced i nvf reqz finds a filter to fit the frequency data for any order filter a third order example is bb aa invfreqgz h w 3 3 find third order IIR bb 0 0464 0 1785 0 2446 0 1276 aa 1 0000 0 9502 0 7382 0 2006 Bothi nvfreqs andinvfreqz design filters with real coefficients for a data point at positive frequency f the functions fit
182. age delay of the filter asa function of frequency It is defined as the negative first derivative of a filter s phase response If the complex frequency response of a filter is H e then the group delay is _ _d0 T Go where 0 is the phase angle of H d Compute group delay with gd w grpdelay b a n which returns then point group delay T0 of the digital filter specified by b and a evaluated at the frequencies in vector w The phase delay of a filter is the negative of phase divided by frequency 2 tpo 2 Frequency Response To plot both the group and phase delays of a system on the same graph b a butter 10 200 1000 gd grpdelay b a 128 h f freqz b a 128 2000 pd unwrap angle h 2000 2 pi f plot f gd f pd axis 0 1000 30 30 legend Group Delay Phase Delay 30 T 1 Group Delay ie Phase Delay 207 J 200 400 600 800 1000 1 29 1 Signal Processing Basics Zero Pole Analysis Thezpl ane function plots poles and Zeros of a linear system For example a simple filter with a O at 1 2 and a complex pole pair at 0 9e and 0 9e 773 is zer 0 5 pol 9 exp j 2 pi 0 3 3 The zero pole plot for the filter is zplane zer pol il ad 0 8F af 0 6 4 0 44 J 0 2 4 oF o J Imaginary part 0 2 J 0 44 0 6 08i J 1F z i f i f f 1 0 5 0 0 5 1 Rea
183. agnitude Response dB w 1 oO if O L i L L in L L 100 150 200 250 300 350 400 450 500 Frequency Hertz e a oOo 50 T r Phase degrees 1 L i 1 L 1 L 50 100 150 200 250 300 350 400 450 500 6 119 ellipord Now design a bandpass filter with a passband from 100 Hz to 200 Hz less than 3 dB of ripplethroughout the passband and 30 dB stopbands 50 Hz out on both sides of the passband Wp 100 200 500 Ws 50 250 500 Rp 3 Rs 30 n Wn elli pord Wp Ws Rp Rs n Wn 0 2000 0 4000 b a ellip n Rp Rs Wn freqz b a 512 1000 n 3 Elliptic Bandpass Filter Sead 4 200 4 Magnitude Response dB L L L L L L L L 0 50 100 150 200 250 300 350 400 450 500 Frequency Hertz 400 T Phase degrees 74995 50 1 00 1 50 200 250 300 350 400 450 500 Frequency Hertz Algorithm ell i pord uses the elliptic lowpass filter order prediction formula described in 1 The function performs its calculations in the analog domain for both the analog and digital cases For the digital case it converts the frequency parameters tothe s domain before the order and natural frequency estimation process then converts them back to the z domain 6 120 ellipord See Also References ellipord initially develops a lowpass filter prototype by transforming the passband frequencies of the desired filter to 1 rad se
184. agnostics The following diagnostic messages arise from incorrect usage of cr emez Not enough input arguments F must contain an even number of band edge entries Band edges must be monotonically increasing Expecting a string argument Invalid argument arg specified Invalid default symmetry option sym returned from response function fresp Must be one of none real even or odd Frequency band edges must be in the range 1 1 for designs with SYM sym Frequency band edges must be in the range 0 1 for designs with SYM sym Incorrect size of results fromresponse function fresp Sizes must be the same size as the frequency grid GF Both 1 and 1 have been specified as frequencies in F and the frequency spacing is too close to move either of themtoward its neighbor Internal error Grid frequencies out of range Internal error domain must be whole or half Internal error obtained a negative bandwidth Internal error two extremal frequecies at the same grid point Internal error dBrange must be gt 0 6 82 cremez See Also References firl fir2 firls remez private bandpass private bandstop private differentiator private highpass private hilbfilt private lowpass private multi band Window based finite impulse response filter design standard response Window based finite impulse response filter design arbitrary response Least square linear phase FI
185. al vector xx with an eigenvalue cutoff of 10 above the minimum Settingp Inf forces the signal noise subspace pmusic Algorithm decision to be based ont hr es h Use eigenvectors of dimension 7 anda sampling frequency Fs of 8 kHz PP ff pmusic xx Inf 1 1 8000 7 window length 7 With the third and fourth outputs by plotting the zeros of the noise eigenvector polynomials it is possible to create a Root MUSIC algorithm as the followingzp ane plot illustrates PP ff v_noise pmusic xx 4 for kk 1 size v_noise 2 rr kk roots v_noise kk end zplane rr Assume that RR is a square correlation matrix for example 7 by 7 RR toeplitz cos 0 1 pi 0 6 0 1 eye 7 PP ff pmusic RR 4 corr Make an observation matrix xx that is rectangular 100 by 7 xx reshape cos 0 257 pi 0 699 7 100 0 1 randn 7 100 PP ff pmusic xx 4 Use the same signal but let pmusi c form the 100 by 7 data matrix using its window and overlap inputs In addition use a longer FFT yy xx PP ff pmusic yy 4 512 7 0 If wesetp 0 all the eigenvectors are assigned to the noise subspace ev specifies the eigenvector weighting This turns out to be equivalent to MVDL Capon s MLM PP ff pmusic RR 0 ev corr The MUSIC estimate is given by the formula P nusi f z N 2 o vo ken E ech k p 1 k p 1 6 231 pmusic Diagnostics 6 232
186. ame filter You can move back and forth between the Filter Designer and the Filter Viewer until the filter design is finished You can apply the filter to a signal by activating SPTool selecting the filter in the Filters list and the signal to apply it to from the Signals list and pressing Apply See Applying a Filter on page 5 19 for details See Using the Filter Viewer Interactive Filter Analysis on page 5 74 for more information on the Filter Viewer 5 73 5 Interactive Tools Using the Filter Viewer Interactive Filter Analysis An important aspect of filter design is filter analysis which encompasses both frequency and time domain analysis of a filter The Filter Viewer is a GUI based frequency analysis tool that provides an interactive environment for the graphical display of digital filter characteristics TheFilter Viewer can display six different characteristics subplots of a selected filter Any combination of the six subplots may be displayed Using the Filter Viewer you can View magnitude response plots for one or more filters View phase response plots for one or more filters View group delay plots for one or more filters View zero pole plots for one or more filters View impulse response plots for one or more filters View step response plots for one or more filters Zoom in to explore filter response details Modify selected plot parameters and display characteristics Measure a variety of characteri
187. an zoomin on a specific area of the display See Zoom Controls on page 5 30 e You can mark off a segment of the display with the rulers see Ruler Controls on page 5 32 and save ruler settings see Save Rulers Button on page 5 36 e You can select a segment of the display with the panner see Panner Display on page 5 51 e You can make certain measurements on the displayed signals see Making Signal Measurements on page 5 37 e When there is more than one signal in the display you can select which one you want to measure see Selecting a line to measure on page 5 33 You can use the other GUI tools to manipulate signals in a variety of ways e You can interactively design and analyze filters to be applied to signals See Using the Filter Designer Interactive Filter Design on page 5 55 and Using the Filter Viewer Interactive Filter Analysis on page 5 74 e You can create a spectrum for a signal and interactively analyze its spectral density with a variety of estimation methods see Using the Spectrum Viewer Interactive PSD Analysis on page 5 88 You access the Filter Designer Filter Viewer and Spectrum Viewer tools from SPTool You can access SPT ool from the Signal Browser by e Clicking on an active SPTool window or e Activating SPTool using the Window menu in the Signal Browser Saving Signal Data After creating a signal in SPTool by applying a filter to an impor
188. and Rs are specified in dB Press Apply to draw the magnitude response Deselect Minimum Order and specify a filter order of 7 Press Apply to redraw the magnitude response Using the Filter Designer Interactive Filter Design The Filter Designer calls the appropriate filter design function to create the filter ji tot Tiha Dag Ee E E To zoom in on plot details use the zoom control buttons as described in Zoom Controls on page 5 30 Filter Design O ptions When the Minimum Order option is disabled you can specify parameters that define characteristics unique to certain filter types e For Butterworth filters the 3 dB frequencies e For Chebyshev type filters the passband edge frequencies e For Chebyshev type I filters the stopband edge frequencies e For elliptic filters the passband edge frequencies 5 67 5 Interactive Tools 5 68 In the following example redesign the Chebyshev type filter from the previous example as a Butterworth filter using a 3 dB frequency of 800 Hz 1 Select the Butterworth IIR filter design from the Algorithm menu The magnitude response plot changes to reflect the new design 2 Typea value of 800 in the F3db text field 3 Press Apply to update the response plot Order Selection for IIR Filter Design The IIR filter design options available through the Filter Designer call the toolbox filter design functions In calculating the order for a given filter th
189. and are intended for interpolation and decimation Design a digital interpolation filter to upsample a signal by four using the bandlimited method alpha 0 5 bandlimitedness factor hl intfilt 4 2 alpha bandlimited interpolation The filter h1 works best when the original signal is bandlimited toa pha times the Nyquist frequency Create a bandlimited noise signal randn seed 0 x filter fir1 40 0 5 1 randn 200 1 bandlimit Now zero pad the signal with three zeros between every sample The resulting sequence is four times the length of x xr reshape x zeros length x 3 4 length x 1 Interpolate using thef i ter command y filter hl 1 xr intfilt Algorithm See Also References y is an interpolated version of x delayed by seven samples the group delay of the filter Zoom in on a section to see this plot 100 200 y 100 200 7 101 4 196 x 26 49 0 Solid interpolated o original 1 5 T T T T 1 0 5 5 1 1 1 100 110 120 130 140 150 160 170 180 190 200 Sample Number intfilt s other type of filter performs Lagrange polynomial interpolation of the original signal For example first order polynomial interpolation is just linear interpolation which is accomplished with a triangular filter h2 intfilt 4 1 I Lagrange interpolation h2 0 2500 0 5000 0 7500 1 0000 0 7500 0 5000 0 2500 The bandlimited method uses f i r
190. and times or sample intervals in column vector t wheret 0 n 1 andn isthe computed impulse response length h t impz b a n Computes n samples of the impulse response Ifn isa vector of integers i mpz computes the impulse response at those integer locations where 0 is the starting point of the filter h t impz b a n Fs computesn samples and scales t sothat samples are spaced 1 Fs units apart Fs is 1 by default h t impz b a Fs chooses the number of samples for you and scales t sothat samples are spaced 1 Fs units apart i mpz with no output arguments plots the impulse response in the current figure window usingstem t h i mpz works for both real and complex input systems 6 179 impz Example Algorithm 6 180 Plot the first 50 samples of the impulse response of a fourth order lowpass elliptic filter with cutoff frequency of 0 4 times the Nyquist frequency b a ellip 4 0 5 20 0 4 impz b a 50 0 5 0 4 0 3 9 0 2 e 0 17 of hahaha 0 1 F 0 2 L L L L ie L 1 L L 0 5 10 15 20 25 30 35 40 45 i mpz filters a length n impulse sequence using filter b a 1 zeros 1 n 1 To computen in the auto length case i mpz either uses n ength b for the FIR case or first finds the poles usingp roots a iflength a is greater than 1 If the filter is unstable n is chosen to be the point at which the term from the largest pole reaches 10 6 times it
191. apabilities this menu choice does nothing The entire selected signal is played at either Fs the sampling frequency of the signal or at the default platform sampling frequency if Fs is less than 25 Hz The real part and theimaginary part of a complex signal are played in separate channels Window Menu Use the window menu to select a currently open MATLAB Figure window 5 43 5 Interactive Tools 5 44 Zoom Controls The available zoom controls in the Signal Browser are Mouse Zoom Full View Zoom In Y Zoom Out Y Zoom In X and Zoom Out X See Zoom Controls on page 5 30 for details on using the zoom controls in the Signal Browser Zoom persistence is off by default in the Signal Browser use the Signal Browser settings panel in Preferences to toggle zoom persistence on and off See Signal Browser Settings on page 5 24 Ruler and Line Display Controls Using the rulers and line display controls you can measure a variety of characteristics of signals in the Signal Browser See Ruler Controls on page 5 32 for details on using rulers and modifying line displays in the Signal Browser Therulers are displayed by default in the Signal Browser you can turn off the ruler display in the Signal Browser settings panel in the Preferences dialog box See Signal Browser Settings on page 5 24 Help Button To use context sensitive help click on the Help button The mouse pointer becomes an arrow with a quest
192. applies a fifth order Butterworth lowpass filter usingfiltfilt xl y cos 2 pi Fc t x2 y sin 2 pi Fc t b a butter 5 Fc 2 Fs filtfilt b a xl filtfilt b a x2 The default method is am Except for the ptm and pwm cases x isthe same Size as y Ify is a matrix demod demodulates its columns x demod y Fc Fs pwm centered finds the pulse widths assuming they are centered at the beginning of each period x is length length y Fc Fs 6 99 demod See Also modulate Modulation for communications simulation vco Voltage controlled oscillator 6 100 detrend Purpose Syntax Description Algorithm See Also Remove linear trends y detrend x y detrend x 0 det rend removes the mean value or linear trend from a vector or matrix usually for FFT processing y detrend x removes the best straight linefit from vector x and returns it iny Ifx isan array det rend removes the trend from each column y detrend x 0 removes the mean value from vector x or ifx iS an array from each column of the array detrend computes the least squares fit of a straight line to the data and subtracts the resulting function from the data The main part of the algorithm is m length x a 1 m m ones m 1 y x a a x To obtain the equation of the straight line fit usepol yfit polyfit Polynomial curve fitting see the online MATLAB Function Reference 6 101 dftm
193. ary perhaps multiband frequency response This section discusses the yul ewal k function which is intended specifically for filter design Parametric Modeling in Chapter 4 discusses other methods that may also be considered direct such as Prony s method Linear Prediction the Steiglitz M cBride method and inverse frequency design yul ewal k designs recursive IIR digital filters by fitting a specified frequency response yul ewal k s name reflects its method for finding the filter s denominator coefficients it finds the inverse FFT of the ideal desired power spectrum and solves the modified Y ule Walker equations using the resulting autocorrelation function samples The statement b a yulewal k n f m returns row vectors b anda containing then 1 numerator and denominator coefficients of the order n IHR filter whose frequency magnitude characteristics approximate those given in vectorsf andm f is a vector of frequency points ranging from 0 to 1 where 1 represents the Nyquist frequency m is a vector containing the desired magnitude response at the points in f f and m can describe any piecewise linear shape magnitude response including a multiband response The FIR counterpart of this function is f i r 2 which also designs a filter based on an arbitrary piecewise linear magnitude response See FIR Filter Design on page 2 16 for details Note that yu ewal k does not accept phase information and no statements a
194. at each frequency in grid gf The predefined frequency response function f resp that remez calls is remezfrf inthesi gnal private directory b remez n f fresp pl p2 w allows you to specify additional parameters p1 p2 etc topass tofresp Notethatb remez n f a w isa synonym forb remez n f remezfrf a w wherea is a vector containing the desired amplitudes at the points specified inf b remez n f fresp w ftype and b remez n f fresp pl p2 w ftype design antisymmetric odd rather than symmetric even filters where ftype iseither d fora differentiator or h for a Hilbert transformer In the absence of a specification for f t ype a preliminary call is made tof resp to determine the default symmetry property s ym This call is made using the syntax sym fresp defaults n f w pl p2 The arguments n f w etc may be used as necessary in determining an appropriate value for s ym which r emez expects tobeeither even or odd If thef resp function does not support this calling syntax r emez defaults to even symmetry remez b delta remez returns themaximum ripple height in delta b delta opt remez returns a structure opt of optional results with the following fields opt opt opt opt opt opt opt fgrid des wt H error iextr fextr Frequency grid vector used for the filter design optimization Desired frequency re
195. at which the stopband begins and the filter has magnitude response of 10 R5 20 H s Algorithm Chebyshev type II filters are sometimes called inverse Chebyshev filters because of their relationship to Chebyshev type filters Thecheb2ap function is a modification of the Chebyshev type prototype algorithm 1 cheb2ap replaces the frequency variable with 1 turning the lowpass filter into a highpass filter while preserving the performance at 1 2 cheb2ap subtracts the filter transfer function from unity See Also bessel ap Bessel analog lowpass filter prototype buttap Butterworth analog lowpass filter prototype cheblap Chebyshev type analog lowpass filter prototype cheby2 Chebyshev type I1 filter design stopband ripple ellipap Elliptic analog lowpass filter prototype References 1 Parks T W and C S Burrus Digital Filter Design New York J ohn Wiley amp Sons 1987 Chapter 7 cheb2ord Purpose Syntax Description 6 46 Chebyshev type II filter order selection n Wn cheb2ord Wp Ws Rp Rs n Wn cheb2ord Wp Ws Rp Rs s cheb2ord selects the minimum order digital or analog Chebyshev typeI filter required to meet a set of filter design specifications Wp Passband corner frequency Wp the cutoff frequency has a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Ws Stopband corner frequency Ws is in the same units as Wp it has
196. ata The spectrum structure also contains a number of fields that are used internally by SPTool To see the fields of the spectrum structure try exporting a spectrum to the workspace 1 Create a new spectrum if none are currently loaded Label the spectrum spectl 2 In SPToodl select Export from the File menu 3 Inthe Export dialog box select s pect 1 and press the Export to Workspace button 4 Typewho at the MATLAB command line to look at the variables in the workspace The variable called spect 1 is the spectrum structure you exported from SPTool 5 Typespect1 to list the fields of the spectrum structure Using the Spectrum Viewer Interactive PSD Analysis The following structure fields describe the spectrum Field Description P The spectral power vector f The spectral frequency vector confid A structure containing the confidence intervals data e Theconfid evel field contains the chosen confidence level e Theconfid Pc field contains the spectral power data for the confidence intervals e Theconfid enable field contains a1 if confidence levels are enabled for the spectrum signal Label The name of the signal from which the spectrum was generated Fs The associated signal s sample rate The other fields are used internally by SPTool and are subject to change in future releases 5 99 5 Interactive Tools Example Generation of Bandlimited Noise This section provides a complete
197. ation Thekai ser ord function estimates the filter order cutoff frequency and Kaiser window beta parameter needed to meet a given set of specifications Given a vector of frequency band edges anda corresponding vector of magnitudes as well as maximum allowable ripple kai serord returns appropriate input parameters for thef i r 1 function For details on kai ser or d see the reference description in Chapter 6 Multiband FIR Filter Design fir2 The function f i r2 also designs windowed FIR filters but with an arbitrarily shaped piecewise linear frequency response This is in contrast tof i r 1 which only designs filters in standard lowpass highpass bandpass and bandstop configurations The commands n 50 fre 0 ade 5 1 m 1 1 0 0 b fir2 n f m return row vector b containing then 1 coefficients of the order n FIR filter whose frequency magnitude characteristics match those given by vectorsf and m f is a vector of frequency points ranging from 0 to 1 where 1 represents the 2 21 2 Filter Design 2 22 Nyquist frequency mis a vector containing the desired magnitude response at the points specified inf The IIR counterpart of this function isyul ewalk which also designs filters based on arbitrary piecewise linear magnitude responses See IIR Filter Design for details Multiband FIR Filter Design with Transition Bands Thefirls andremez functions providea more general means of specifying the ideal desired
198. ative By setting o equal to 0 in the stopbands a nonnegative frequency response amplitude can be obtained Such filters can be spectrally factored to obtain minimum phase filters Algorithm The algorithm is a multiple exchange algorithm that uses Lagrange multipliers and Kuhn Tucker conditions on each iteration 6 145 fircls See Also References 6 146 firclsl Constrained least square filter design for lowpass and highpass linear phase FIR filters firls Least square linear phase FIR filter design remez Parks McClellan optimal FIR filter design 1 Selesnick I W M Lang and C S Burrus Constrained Least Square Design of FIR Filters without Specified Transition Bands Proceedings of the IEEE Int Conf Acoust Speech Signal Processing Vol 2 May 1995 Pgs 1260 1263 2 Selesnick W M Lang and C S Burrus Constrained Least Square Design of FIR Filters without Specified Transition Bands IEEE Transactions on Signal Processing Vol 44 No 8 August 1996 firclsl1 Purpose Syntax Description Constrained least square filter design for lowpass and highpass linear phase FIR filters b firclsl n wo dp ds b firclsl n wo dp ds high b firclsl n wo dp ds wt b firclsl n wo dp ds wt high b firclsl n wo dp ds wp ws k b firclsl n wo dp ds wp ws k high b firclsil n wo dp ds design_flag b fircls1 n wo dp ds generates a
199. ax Description Example Limitations Algorithm 6 234 Reflection coefficients from polynomial coefficients k poly2rc a k poly2rc a finds the reflection coefficients of the lattice structure of the discrete filter a a must be real anda 1 cannot be 0 k is a row vector of size length a 1l A simple fast way to check if a has all of its roots inside the unit circle is to check if each of the elements of k have magnitude less than 1 stable all abs poly2rc a lt l Consider an IIR filter given by a 1 0000 0 6149 0 9899 0 0000 0 0031 0 0082 Its reflection coefficient representation is k poly2rc a k 0 3090 0 9800 0 0031 0 0082 0 0082 Ifabs k i 1 for anyi finding the reflection coefficients is an ill conditioned problem po y2rc will return some Na Ns and provide a warning message in this case pol y2rc implements the recursive relationship k n an n dy m k n ay n m 1 k n a 1 m m 1 2 n 1 poly2rc This relationship is based on Levinson s recursion 1 To implement it pol y2rc loops through a in reverse order after discarding its first element F or each loop iteration i the function 1 setsk i equal toa i 2 applies the second relationship abovetoelements 1 through of the vector a a a k i fliplr a 1 k i 2 See Also latc2tf Lattice filter to transfer function conversion latcfilt Lattice and lattice ladder filter implementation
200. ay in which the local phase angle varies linearly over a single cycle For mixtures of sinusoids the attributes are short term or local averages spanning no more than two or three points Reference 1 describes the Kolmogorov method for minimum phase reconstruction which involves taking the Hilbert transform of the logarithm of the spectrum of a time series The toolbox function r ceps performs this reconstruction The analytic signal for a sequencex has a one sided Fourier transform that is negative frequencies are 0 To approximate the analytic signal hi bert calculates the FFT of the input sequence replaces those FFT coefficients that correspond to negative frequencies with zeros and calculates the inverse F FT of the result hilbert See Also References In detail hi bert uses a four step algorithm 1 It calculates the FFT of the input sequence storing the result in a vector y Before transforming it zero pads the input sequence so its length n is the closest power of two if necessary This ensures the most efficient F FT computation 2 It creates a vector h whose elements h i have the values lfori 1 n 2 1 2fori 2 3 n 2 Ofori n 2 2 n 3 It calculates the element wise product of y and h 4 It calculates the inverse FFT of the sequence obtained in step 3 and returns the first n elements of the result If theinput datax isa matrix hi bert operatesinasimilar manner extending each
201. bandpass 6 202 conversion to bandstop 6 205 conversion to highpass 6 207 conversion to lowpass 6 209 elliptic filter 6 116 frequency response 2 12 plotting 2 12 analog prototype design Bessel 2 38 bilinear transformation 2 42 Butterworth 2 38 Chebyshev 2 38 elliptic 2 38 filter discretization 2 41 frequency transformation 2 38 impulse invariance 2 41 See alsolIR filter design analog signal See signal analytic signal 2 26 6 170 applications 4 37 properties 4 37 angle 6 2 6 12 anti symmetric filter 2 25 Apply button Spectrum Viewer 5 88 Index Apply Filter button 5 19 applying parameters with Apply button 5 91 AR model 4 11 ARMA filter 1 15 See also lIR filter ARMA model 4 12 4 14 Prony s method 4 12 Steiglitz M cBride method 4 14 array display in Signal Browser 5 44 5 49 in SPTool 5 15 Array Signals button Signal Browser 5 45 5 49 ARX model 4 13 ASCII file importing 1 13 attenuation stopband 5 62 attributes instantaneous 6 170 autocorrelation 4 11 6 324 multiple channels 3 4 two dimensional 6 329 autocovariance 6 330 multiple channels 3 4 autoregressive AR filter 1 15 See also lIR filter autoregressive moving average ARM A filter 1 15 See also lIR filter auto spectrum in SPTool 5 15 averaging filter 1 14 axis labels in Signal Browser 5 21 5 24 axis parameters in Filter Viewer 5 21 in Spectrum Viewer 5 21 axis scaling range in Filter Viewer 5 27 5 77 in Spectrum Viewer 5 25 5 90 5 93 axi
202. boxcar 4 2 6 7 6 27 example 4 2 boxcar window Seerectangular window Burg method 3 5 3 6 3 20 compared to Welch s method 3 22 defined 3 20 Burg method in Spectrum Viewer 5 95 buttap 2 5 6 9 6 28 example 2 8 butter 2 5 2 6 6 4 6 29 accessing from Filter Designer 5 55 Butterworth filter analog 6 30 analog prototype 2 8 2 38 6 28 bandpass configuration analog 6 31 digital 6 29 bandstop configuration analog 6 31 digital 6 30 characteristics 2 8 design 6 29 digital 6 29 generalized 2 14 highpass configuration analog 6 31 digital 6 30 limitations 6 33 lowpass configuration analog 6 30 digital 6 29 order estimation 2 7 6 34 buttord 2 5 6 5 634 C canonical forms 1 17 6 308 carrier frequency 4 28 6 218 6 322 carrier signal 4 28 6 98 cascade digital filter 1 37 Cauer filter See elliptic filter cceps 4 23 6 8 6 38 example 4 23 center frequency 2 40 central features 1 2 cepstrum applications 4 23 complex 4 23 inverse 4 23 4 25 overview 4 23 real 4 23 Index cepstrum cont See also real cepstrum complex cepstrum cepstrum analysis 4 23 cheblap 2 5 6 9 6 40 example 2 9 2 39 cheblord 2 5 6 5 6 41 cheb2ap 2 5 6 9 6 45 example 2 10 heb2ord 2 5 6 5 6 46 ebwin 4 2 6 7 6 50 eby1 2 5 2 6 6 4 6 51 accessing from Filter Designer 5 55 example 2 44 cheby2 2 5 2 6 6 4 6 56 accessing from Filter Designer 5 55 Chebyshev error minimization 2 22 6 255 Chebyshev type filter analo
203. c for low and highpass filters and to 1 and 1 rad sec for bandpass and bandstop filters It then computes the minimum order required for alowpass filter to meet the stopband specification buttord cheblord cheb2ord ellip Butterworth filter order selection Chebyshev type filter order selection Chebyshev type II filter order selection Elliptic Cauer filter design 1 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pg 241 6 121 fft Purpose Syntax Description Example 6 122 One dimensional fast F ourier transform fft x fft x n y y f ft computes the discrete Fourier transform of a vector or matrix This function implements the transform given by N 1 Xk Yo xn wE n 0 where Wy e 27 and N ength x Note that the series is indexed as n 1landk 1 instead of the usual n and k because MATLAB vectors run from 1toN instead of from 0 to N 1 y fft x isthediscrete Fourier transform of vector x computed with a fast Fourier transform FFT algorithm If x isa matrix y istheFFT of each column of the matrix Thef ft function employs a radix 2 fast Fourier transform algorithm if the length of the sequence is a power of two and a slower algorithm if it is not see the Algorithm section for details y fft x n isthen point FFT Ifthe length of x islessthann fft padsx with trailing zeros to length n
204. c sinc function gauspuls Gaussian modulated sinusoidal pulse generator pulstran Pulse train generator rectpuls Sampled aperiodic rectangle generator sawtooth Sawtooth or triangle wave generator Sin Sine of vector matrix elements See the online MATLAB Function Reference sinc Sinc or sin xt rt function Square Square wave generator unwrap Purpose Syntax Description Limitations See Also Unwrap phase angles p unwrap p p unwrap p corrects the phase angles in vector p by adding multiples of 27 where needed to smooth the transitions across branch cuts When p isa matrix unwrap corrects the phase angles down each column The phase must bein radians This function is part of the standard MATLAB environment unwrap tries to detect branch cut crossings but it can be fooled by sparse rapidly changing phase values abs Absolute value magnitude angle Phase angle 6 317 upfirdn Purpose Syntax Description 6 318 Upsample apply an FIR filter and downsample yout upfirdn xin h yout upfirdn xin h p yout upfirdn xin h p q upfirdn performs a cascade of three operations 1 Upsampling by p zero inserting 2 FIR filtering with the impulse response given in h 3 Downsampling by q throwing away samples upfi rdn has been implemented as a ME X file for maximum speed so only the outputs actually needed are computed The FIR filter is usually a lowpass filter w
205. cBride method is a fast iterative algorithm that solves for the numerator and denominator coefficients simultaneously in an attempt to minimize the signal error between the filter output and the given output signal This algorithm usually converges rapidly but might not converge if the model order is too large As for prony stmcb s resulting filter is not necessarily stable due to its exact modeling approach stmcb provides control over several important algorithmic parameters modify these parameters if you are having trouble modeling the data To change the number of iterations from the default of five and provide an initial estimate for the denominator coefficients n 10 number of iterations a pc x 3 initial estimates for denominator b a stmcb x 3 3 n a The function uses an all pole model created with prony as an initial estimate when you do not provide one of your own 4 15 4 Special Topics To compare the functions pc prony andst mcb compute the signal error in each case al pc x 3 b2 a2 prony x 3 3 b3 a3 stmcb x 3 3 x impz 1 a1 10 x impz b2 a2 10 x impz b3 a3 10 ans 0 1165 0 0 0 0058 0 0 0190 0 0535 0 0000 0 0818 0 0151 0 0000 0 0176 0 1473 0 1143 0 0476 0 2005 0 1897 0 0869 0 0233 0 0154 0 0103 0 1901 0 1669 0 0093 0 0275 0 0251 0 0294 0 0808 0 0751 0 0022 Sum ans 2 ans 0 1226 0 0834 0 0182 In comparing modeling cap
206. ces a matrix whose columns oscillate according tothe columns of x Generate two seconds of a signal sampled at 10 000 samples second whose instantaneous frequency is a triangle function of time Fs 10000 t Q 1 Fs 2 x vco sawtooth 2 pi t 0 75 1 0 4 Fs Fs vco Plot the spectrogram of the generated signal specgram x 512 Fs kaiser 256 5 220 5000 4500 4000 3500 3000 gt 2 C 3 2500 Ww 0 2 0 4 0 6 0 8 1 1 2 1 4 1 6 1 8 Time Algorithm vco performs FM modulation using the modulate function Diagnostics If any values of x lie outside 1 1 vc o gives the following error message X outside of range 1 1 See Also demod Demodulation for communications simulation modulate Modulation for communications simulation 6 323 xCcorr Purpose Syntax Description 6 324 Cross correlation function estimate xcorr x y xcorr x xcorr x y option xcorr x y maxl ags c xcorr x y maxlags option c lags xcorr x y c lags xcorr x y maxl ags c lags xcorr x y maxlags option aA A 0 xcorr estimates the cross correlation sequence of random processes Autocorrelation is handled as a special case The true cross correlation sequence is Yxy M E X YA m where x and y are stationary random processes 0 lt n lt oo andE fis the expected value operator xc orr must estimate the sequence because in practice access is available to o
207. cessing functions e Graphical interactive tools The first category of tools is made up of functions that you can call from the command line or from your own applications Many of these functions are MATLAB M files series of MATLAB statements that implement specialized signal processing algorithms You can view the MATLAB code for these functions using the statement type function_name or by opening the M file in the MATLAB Editor Debugger Y ou can change the way any toolbox function works by copying and renaming the M file then modifying your copy You can also extend the toolbox by adding your own M files Secondly the tool box provides a number of interactive tools that let you access many of the functions through a graphical user interface GU1 The GUI based tools provide an integrated environment for filter design analysis and implementation as well as signal exploration and editing For example with the graphical user interface tools you can e Use the mouse to graphically edit the magnitude response of a filter or measure the slope of a signal with onscreen rulers e Play a signal on your system s audio hardware by selecting a menu item or pressing a corresponding keystroke combination e Customize the parameters and method of computing the spectrum of a signal How to Use This M anual How to Use This Manual If you are a new user Begin with Chapter 1 Signal Processing Basics This chapter introduces the MATLA
208. cking on the edge of a horizontal green line the mouse pointer changes to 4 and dragging the edge to a new frequency or by clicking anywhere on a vertical green line if the Filter Designer provides one and dragging it horizontally toa new frequency The Fp and Fs values displayed in the Specifications panel change as you drag If Auto Design is checked the response plot also updates as you drag the lines If Auto Design is disabled the response plot updates when you release the mouse See Redesigning a Filter Using the Magnitude Plot on page 5 68 for details Measurement Lines A number of the filter designs provide rulers on the response plot that allow you to measure response magnitude levels These measurement lines which appear in red on the plot are available for the K aiser window Butterworth Using the Filter Designer Interactive Filter Design Chebyshev type I and Chebyshev type I filters when the Minimum Order check box is not selected As you drag a measurement line the corresponding values in the Measurements panel change to reflect the measurement line s current position Designing Finite Impulse Response FIR Filters The Filter Designer provides three options for basic FIR filter design These options allow you to create FIR filters with standard band configurations lowpass highpass bandpass or bandstop configurations only The three options for FIR filter design in the Algorithm pop up menu are
209. closes the Preferences window Settings in all panels are saved in a MAT filecalledsi gprefs mat Ifsi gprefs mat does not exist either on the current MATLAB path or in the current directory you are prompted for a location to save the file The saved settings are used the next time you open SPT ool Controls for Viewing and Measuring The GUI tools share common controls for viewing and measuring signals These controls are described in this section Not all tools use all of the viewing and measuring controls specific details about the tools and procedures for viewing and measuring are described in the section on each tool Zoom Controls TheGUI tools share a common set of zoom control buttons The Signal Browser and Spectrum Viewer use the same set of common zoom control buttons Fa lt gt Zoom Zoom Zoom 2oom In Y Dut Y In Out x The Filter Designer has one additional viewing button the Pass Band button z s pa ae VU Zoom Zoom Zoom Zoom Pass In Y Out Y In Out Band The Filter Viewer has a subset of the zoom control buttons Each button works the same way in every GUI tool where it occurs In normal use you click a button once to zoom in or out of the signal display Using SPTool Zoom In X Zoom Out X Zoom In Y and Zoom Out Y Click once to perform one zoom operation in or out on the x or y axis Each zoom operation changes the axes limits by a factor of two on the specified axis ab
210. columns of X c lags xcov x y maxlags option Specifies a scaling option where option isthe last input argument In all cases xcov gives an output such that the zeroth lag of the covariance vector is in the middle of the sequence at element or row max ag 1 or at m The second output ags is useful when plotting For example the estimated autocovariance of uniform white noise Gyy m can be displayed for 10 lt m lt 10 using ww randn 1000 1 generate uniform noise with mean 1 2 cov_ww lags xcov ww 10 coeff stem lags cov_ww 6 331 X COV Algorithm Diagnostics See Also References 6 332 xcov computes the mean of its inputs subtracts the mean and then calls xcorr For more information on estimating covariance and correlation functions see 1 and 2 xcov does not check for any errors other than the correct number of input arguments Instead it relies on the error checking in xcorr which it calls conv Convolution and polynomial multiplication corrcoef Correlation coefficient matrix cov Covariance matrix xcorr Cross correlation function estimate xcorr2 Two dimensional cross correlation 1 Bendat J S and A G Piersol Random Data Analysis and Measurenent Procedures New York J ohn Wiley amp Sons 1971 Pg 332 2 Oppenheim A V and R W Schafer Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 63 67 746 747 839 842 yulewalk
211. columns of matrixz with as many columns as there are rows innum The polelocations are returned in column vector p and the gains for each numerator transfer function in vector k tf2zp also works for discrete systems The function zp2tf is the inverse of tf2zp 6 309 tf2zp Example Find the zeros poles and gains of the system H s s 0 4s 1 num 2 3 den 1 0 4 1 z p k tf2zp num den Z 1 5000 p 0 2000 0 9798i 0 2000 0 9798i k 2 Algorithm The system is converted to state space usingt f 2ss and then to zeros poles and gains usingss2zp See Also ss2tf State space to transfer function conversion ss2zp State space to zero pole gain conversion tf2ss Transfer function to state space conversion zp2ss Zero pole gain to state space conversion zp2tf Zero pole gain to transfer function conversion 6 310 tfe Purpose Syntax Description Transfer function estimate from input and output Txy tfe x y Txy tfe x y nfft Txy f tfe x y nfft Fs Txy tfe x y nfft Fs window Txy tfe x y nfft Fs window noverl ap Txy tfe x y dflag tfe x y Txy tfe x y finds a transfer function estimateTxy given input signal vector x and output signal vector y The transfer function is the quotient of the cross spectrum of x andy and the power spectrum of x Pry f Ty f Pf The relationship between the input x and output y is modeled by th
212. computes them using only a few data points A possible trade off is to simply divide by N using the biased flag xcorr x y biased With this scheme only the sample of the correlation at 0 lag the Nth output element is unbiased This estimate is often more desirable than the unbiased one because it avoids random large variations at the end points of the correlation sequence xcorr provides one other normalization scheme The syntax xcorr x y coeff divides the output by nor m x norm y sothat for autocorrelations the sample at 0 lagis 1 Multiple Channels For a multichannel signal xcorr andxcov estimate the autocorrelation and cross correlation and covariance sequences for all of the channels at once If s isan M by N signal matrix representing N channels in its columns xcorr 5S returns a 2M 1 by N2 matrix with the autocorrelations and cross correlations of the channels of in its N columns If is a 3 channd signal S sl s2 3 then the result of xcorr S iS organized as R Rs1s1 Rsls2 Rs1s3 Rs2s1 Rs2s2 Rs2s3 Rs3s1 Rs3s2 Rs3s3 Two related functions cov andcorrcoef are available in the standard MATLAB environment They estimate covariance and normalized covariance respectively between the different channels at lag 0 and arrange them in a square matrix Spectral Analysis Spectral Analysis Spectral analysis seeks to describe the frequency content of a signal random process or system based on a f
213. cs An appropriate diagnostic message is displayed if incorrect arguments are used Filter order must be 3 or more There should be one weight per band Frequency and amplitude vectors must be the same length The number of frequency points must be even Frequencies must lie between 0 and 1 Frequencies must be specified in bands Frequencies must be nondecreasing Adjacent bands not allowed A more serious warning message is Failure to Converge Probable cause is machine rounding error In the rare event that you see this message it is possible that the filter design may still be correct Verify the design by checking its frequency response 6 261 remez See Also References 6 262 butter Butterworth analog and digital filter design chebyl Chebyshev type I filter design passband ripple cheby2 Chebyshev type I1 filter design stopband ripple cremez Complex and nonlinear phase equiripple FIR filter design ellip Elliptic Cauer filter design firl Window based finite impulse response filter design standard response fir2 Window based finite impulse response filter design arbitrary response fircls Constrained least square FIR filter design for multiband filters firclsl Constrained least square filter design for lowpass and highpass linear phase FIR filters firls Least square linear phase FIR filter design firrcos Raised cosine FIR filter design remezord Parks McClellan optimal FIR
214. d Estimate the power spectral density PSD of a signal using Welch s method References 1 Marple S L Digital Spectral Analysis Englewood Cliffs NJ Prentice Hall 1987 Chapter 7 6 251 rc2poly Purpose Syntax Description Example Algorithm See Also References 6 252 Polynomial coefficients from reflection coefficients a rc2poly k a rc2poly k finds the filter coefficients a with a 1 1 from the real reflection coefficientsk of the lattice structure of a discretefilter a is row vector of lengthk 1 Consider an IIR filter given by reflection coefficients k k 0 3090 0 9800 0 0031 0 0082 0 0082 Its polynomial representation is a rc2poly k a 1 0000 0 6149 0 9899 0 0000 0 0031 0 0082 rc2pol y computesa using Levinson s recursion 1 The function 1 Sets the output vector a to the first element of k 2 Loops through the remaining elements of k For each loop iterationi a a a i l 1 1 k i k i 3 Implements a 1 a latc2tf Lattice filter to transfer function conversion latcfilt Lattice and lattice ladder filter implementation poly2rc Reflection coefficients from polynomial coefficients tf2latc Transfer function to lattice filter conversion 1 McClellan J Parametric Signal Modeling Advanced Topics in Signal Processing Oppenheim A V andJ S Lim ed Englewood Cliffs NJ Prentice Hall 1988 Pgs 20 21 rceps Purpose Syntax Desc
215. d deviation from 0 stopband ripple wp is the passband edge of the L2 weight function and ws is the stopband edge of the L2 weight function wherewp lt wo lt ws k is the ratio passband L2 error stopband L2 error Wp 2 J A D do BOGS ee ee ee A a 2 ik A D do b fircls1 n wo dp ds wp ws k high generatesa highpass FIR filter b with a weighted function wherews lt wo lt wp b fircls1 n wo dp ds design_flag enables you to monitor the filter design wheredesign_flag canbe e trace for a textual display of the design table used in the design e plots for plots of the filter s magnitude group delay and zeros and poles e both for both the textual display and plots NOTE In the design of very narrow band filters with small dp andds there may not exist a filter of the given length that meets the specifications firclsl1 Example Design an order 55 lowpass filter with a cutoff frequency at 0 3 n 55 wo 0 3 dp 0 02 ds 0 008 b firclsl n wo dp ds plots plot magnitude response 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Algorithm The algorithm is a multiple exchange algorithm that uses Lagrange multipliers and Kuhn Tucker conditions on each iteration See Also fircls Constrained least square FIR filter design for multiband filters firls Least square linear phase FIR filter design remez Parks McClellan optimal FIR filter design References 1 Selesnick W
216. d u must be the same length x nb na niter and x u nb na niter useniter iterations The default for x nb na niter ai and x u nb na niter ai Usethe vector ai as the initial estimate of the denominator coefficients If ai is not specified st mcb uses the output argument from b ai prony x 0 na asthe vector ai stmcb returns the IIR filter coefficients in length nb 1 andna 1 row vectors b anda The filter coefficients are ordered in descending powers of z H z _ BG _ BA O nb A z atalaz 4 4 a na Ng 6 301 stmcb Example Approximate the impulse response of a Butterworth filter with a system of lower order b a butter 6 0 2 h filter b a 1 zeros 1 100 freqz b a 128 i is is fi Y is is T fi 1 j f f 1 i f i 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 Magnitude Response dB 3 o 7 1 wo S o 0 T T T 400 J Phase degrees t 1 1 1 1 1 1 1 1 1 9g 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyauist 1 bb aa stmcb h 4 4 freqz bb aa 128 20 T T T T 0 4 204 4 40 4 Magnitude Response dB 60 1 1 n i 1 1 L fi fi 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 Normalized frequency Nyquist 1 0 T T T T i 1 f f f f f 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 Normalized frequency Nyquist 1 6 302 stmcb
217. default value for al pha is 0 5 Ly b interp x r alpha returns vector b containing the filter coefficients used for the interpolation Example Interpolate a signal by a factor of four t x y s f s 6 182 0 0 001 1 time vector sin 2 pi 30 t sin 2 pi 60 t interp x 4 tem x 1 30 igure tem y 1 120 Original Signal Interpolated Signal 2 T T 2 1 57 7 1 5 T 4 4h 0 5 1 f J F E lin peH J ob 0 5 i 0 5 ab alk 15 1 5 25 5 10 15 20 25 30 2 20 40 60 80 100 120 interp Algorithm i nter p uses the lowpass interpolation Algorithm 8 1 described in 1 1 It expands the input vector to the correct length by inserting zeros between the original data values 2 It designsa special symmetric FIR filter that allows the original data to pass through unchanged and interpolates between so that the mean square errors between the interpolated points and their ideal values are minimized 3 It applies the filter to the input vector to produce the interpolated output vector The length of the FIR lowpass interpolating filter is 2 r 1 The number of original sample values used for interpolation is 2 Ordinarily should be less than or equal to 10 The original signal is assumed to be band limited with normalized cutoff frequency O lt alpha lt 1 where Lis half the original sampling frequency the Nyquist frequency The default value for is 4 and the default va
218. der 22 equiripple lowpass filter with a sampling frequency of 1 Hz Regardless of how many or what combination of plots is displayed you can zoom in on and pan each subplot independently Viewing Magnitude Response A magnitude response plot is generally the simplest way to obtain a high level view of a filter s shape and fit to specifications In the following example use the Filter Designer to create a standard default filter and then view its magnitude response plot in the Filter Viewer Using the Filter Viewer Interactive Filter Analysis 1 From SPTool click Create The Filter Designer is activated and a standard default filter is created and displayed eo 3 5 E T octal Als dT Wagi 1741 This is an order 22 equiripple lowpass filter with a sampling frequency of 1 Hz 2 Usethe Window menu in the Filter Designer to activate SPT ool 3 Click View from the Filters panel in SPTool to activate the Filter Viewer The Filter Viewer is displayed with a magnitude response plot and a phase response plot 4 Click the check box next to the Phase option to turn off the phase plot 5 81 5 Interactive Tools 5 82 The magnitude plot for the default filter is displayed r of ERS By default this plot uses the default scaling linear for both axes and the default range for the frequency axis You can change the following display characteristics of the magnitude plot e Use the Magnitude pop up
219. deter mination of the system of equations Ifa 1 0 while computing the partial fraction decomposition using r p k residuez b a residuez gives the following error message First coefficient in A vector must be nonzero residuez If the number of residuesr and poles p is not the same resi duez gives the following error message R and P vectors must be the same size See Also convmt x deconv poly prony residue roots ss2tf tf2ss tf2zp zp2ss Convolution matrix Deconvolution and polynomial division see the online MATLAB Function Reference Polynomial with specified roots see the online MATLAB Function Reference Prony s method for time domain IIR filter design Partial fraction expansion see the online MATLAB Function Reference Polynomial roots see the online MATLAB Function Reference State space to zero pole gain conversion Transfer function to state space conversion Transfer function to zero pole gain conversion Zero pole gain to state space conversion References 1 Oppenheim A V and R W Schafer Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 166 170 6 273 saw tooth Purpose Syntax Description Diagnostics See Also 6 274 Sawtooth or triangle wave generator x sawtooth t x sawtooth t width sawtooth t generates a sawtooth wave with period 27 for the elements of timevectort sawtooth t issimilar tosin t bu
220. dialog box 5 26 5 28 FFT method in Spectrum Viewer 5 95 FFT See fast Fourier transform fft2 1 45 6 6 6 126 rearranging output 1 45 FFT based filtering 1 22 fftfilt 1 19 6 2 6127 compared tofilter 6 127 fftshift 1 45 6 6 6 129 File Contents list 5 9 filter analog prototype 2 8 2 11 6 15 6 28 6 40 6 45 6 116 analyzing in Filter Viewer 5 18 applying to a signal 5 19 Butterworth 2 7 6 29 generalized 2 14 Chebyshev 2 7 Chebyshev type 6 51 Chebyshev type I1 6 56 coefficients 1 15 2 17 design FIR 6 255 generalized 2 5 IIR 2 5 inverse 6 186 6 190 discretization 2 41 editing in SPTool 5 18 elliptic 2 7 6 110 equiripple 2 22 group delay 5 18 identification from frequency data 6 186 implementation 1 22 6 127 6 130 importing into SPTool 5 8 5 10 5 12 impulse response 5 18 linear time invariant digital 1 2 magnitude response 5 18 measurements 5 37 median 4 27 6 217 minimax 2 22 minimum phase 6 236 multiband FIR 2 22 Index 1 10 filter cont names 1 15 naming in SPTool 5 17 order 1 15 2 7 6 34 6 41 6 46 6 117 order selection 2 7 phase response 5 18 principal supported 1 2 single band FIR 2 20 specifications 2 7 step response 5 18 transposed direct form II structure 1 17 two dimensional 6 133 types 2 17 viewing in Filter Viewer 5 17 zeros and poles 5 18 Seealso FIR filter IIR filter digital filter an alog filter filter 1 2 1 15 1 20 6 2 6 130 compared tofftfilt 6 127 compared
221. dogram 3 9 Bartlett 4 2 6 13 Blackman 4 4 6 25 boxcar 2 19 Chebyshev 4 9 6 50 for filter design 2 19 generalized cosine 4 4 Hamming 2 20 4 4 6 168 Hanning 4 4 6 169 Kaiser 4 4 6 193 rectangular 2 19 6 27 shapes overview 4 2 specifying for f i r1 2 21 triangular 6 315 window method FIR filter design 2 18 multiband design 2 21 single band design 2 20 window method FIR filter design bandpass configuration 6 137 bandstop configuration 6 137 highpass configuration 6 137 lowpass configuration 6 137 Workspace Contents list in Import dialog box 5 9 workspace loading variables from 5 9 X X Label edit box in Preferences dialog box 5 24 xcorr 3 2 6 7 6 324 and parametric modeling 4 12 xcorr2 6 7 6329 xcov 3 2 6 7 6 330 Y Y Label edit box in Preferences dialog box 5 24 YuleAR method in Spectrum Viewer 5 97 yulewalk 2 5 2 13 4 11 6 4 6 333 example 2 14 Yule Walker AR method 3 5 3 6 3 19 4 11 compared to Welch s method 3 20 defined 3 19 example 3 20 Yule Walker equations 2 13 Yule Walker filter design 6 333 Z zerofrequency component centering withfftshift 1 45 zero order hold See averaging filter zero phase filtering 6 134 zero pole analysis example 1 30 zero pole plots 6 341 zero pole gain 1 42 zero pole plot 5 77 5 85 viewing in Filter Viewer 5 85 Index zero pole gain form 1 40 converting to second order section 6 336 converting to state space 6 339 defined 1 33 in SPTool 5 13
222. ds 3 22 3 Statistical Signal Processing 3 2 Correlation and Covariance The Signal Processing Toolbox provides tools for estimating important functions of random signals In particular there are tools to estimate correlation and covariance sequences and spectral density functions of discrete signals This chapter explains the correlation and covariance functions and discusses the mathematically related functions for estimating the power spectrum The functions xcorr and xcov estimate the cross correlation and cross covariance sequences of random processes They also handle autocorrelation and autocovariance as special cases The true cross correlation sequence is a statistical quantity defined as Yxy M E X Vn m where x and yp are stationary random processes lt n lt and E is the expected value operator The cross covariance sequence is the mean removed cross correlation sequence Cyy M E Xp H Yh m HY I or in terms of the cross correlation Cyy M Yyxy M u H In practice you must estimate these sequences because it is possible to access only a finite segment of theinfinite length random process A common estimate based on N samples of x and y is the deterministic cross correlation sequence also called the time ambiguity function N I ml 1 A XnYntm m20 R y m 9 n 0 Ryy m m lt 0O Correlation and Covariance where we assume for this discussion that x
223. e followed by the zero pole gain form The transfer function coefficient form is the least accurate numerical problems can arise for filter orders as low as 15 butter uses a five step algorithm 1 t finds thelowpass analog prototype poles zeros and gain using theb ut t ap function 2 It converts the poles zeros and gain into state space form 3 Ittransforms thelowpass filter into a bandpass highpass or bandstop filter with desired cutoff frequencies using a state space transformation 4 For digital filter design butter usesbilinear toconvert the analog filter into a digital filter 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 or w1 and w2 5 It converts the state space filter back to transfer function or zero pole gain form as required bessel f buttap buttord chebyl cheby2 ellip maxfl at Bessel analog filter design Butterworth analog lowpass filter prototype Butterworth filter order selection Chebyshev type filter design passband ripple Chebyshev type II filter design stopband ripple Elliptic Cauer filter design Generalized digital Butterworth filter design 6 33 buttord Purpose Syntax Description 6 34 Butterworth filter order selection n Wn buttord Wp Ws Rp Rs n Wn buttord Wp Ws Rp Rs s but
224. e Filter Designer uses the corresponding order estimation function if the Minimum Order check box is selected For details on order selection with the IIR filter design options see the reference descriptions of buttord cheblord cheb2ord andellipord in Chapter 6 Redesigning a Filter Using the Magnitude Plot After designing a filter in the Filter Designer you can redesign it by dragging the specification lines in the magnitude plot Use the specification lines to change passband ripple stopband attenuation and edge frequencies see Specification Lines on page 5 62 for details In the following example create a Chebyshev filter and modify it by dragging the specification lines 1 Create a Chebyshev type highpass filter with a sample frequency of 2000 Hz Set the following parameters Fp 800 Fs 700 Rp 2 5 Rs 35 2 Check Minimum Order sotheF ilter Designer can calculate the lowest filter order that produces the desired characteristics 3 Press Apply to update the response plot Using the Filter Designer Interactive Filter Design 4 Position the cursor over the green line specifying the stopband The cursor changes to the up down drag indicator 5 Dragtheline until the Rs stopband attenuation field reads 100 Note that the Order value in the Measurements panel changes because a higher filter order is needed to meet the new specifications Saving Filter Data After designing a filter in the Filter Designer
225. e interval of 95 Specify a length 1024 FFT a 500 point triangular window with no overlap and a sampling frequency of 10 Hz firl 30 0 2 boxcar 31 1 ones 1 10 sqrt 10 randn 16384 1 filter hl 1 r filter h 1 x h h r X y csd x y 1024 10000 triang 500 0 Cross Spectrum Magnitude dB a A or NX an e ro e o D i 4 oO 0 1000 2000 3000 4000 5000 Frequency csd Algorithm Diagnostics See Also csd implements the Welch method of spectral density estimation see references 1 and 2 1 It applies the window specified by the wi ndow vector to each successive detrended section 2 It transforms each section with an nf f t point FFT 3 It forms the periodogram of each section by scaling the product of the transform of they section and the conjugate of the transformed x section 4 It averages the periodograms of the successive overlapping sections to form Pxy the cross spectral density of x andy The number of sections that csd averages isk wherek is fix length x noverlap length wi ndow noverl ap An appropriate diagnostic message is displayed when incorrect arguments to csd are used Requires window s length to be no greater than the FFT length Requires NOVERLAP to be strictly less than the window length Requires positive integer values for NFFT and NOVERLAP Requires vector either row or column input Requires inputs X and Y to hav
226. e or type ll linear phase filters depending on whether the order you desire is even or odd respectively A lowpass example with approximate amplitude 1 from 0 to 0 4 Hz and approximate amplitude 0 from 0 5 to 1 0 Hz is n 20 filter order f 0 4 5 1 frequency band edges a l 1 0 0 desired amplitudes b remez n f a FIR Filter Design From 0 4 to 0 5 Hz r emez performs no error minimization this is a transition band or don t care region A transition band minimizes the error more in the bands that you do care about at the expense of a slower transition rate In this way these types of filters have an inherent trade off similar to FIR design by windowing To compare least squares to equiripple filter design usefi ris to create a similar filter bb firls n f a and compare their frequency responses H w freqz b HH w f reqz bb plot w pi abs H w pi abs HH grid 1 0 8 a LET 2 0 4 0 2 05 1 10 10 10 Frequency rad sec You can see that the filter designed with r emez exhibits equiripple behavior Also note that thef iris filter has a better response over most of the passband and stopband but at the band edges f 0 4 andf 0 5 the response is further away from the ideal than ther emez filter This shows that ther e mez filter s maximum error over the pass and stopbands is smaller and in fact it is the smallest possible for this band edge con
227. e y axis x2 the position of ruler 2 on the x axis y2 the position of ruler 2 on Using SPTool the y axis dx the value of x2 x1 dy the value of y2 y1 and m equal to dy dx the slope of the line between x1 and x2 Click Slope to put the rulers in slope mode In slope mode you may change the x values of the rulers that is their horizontal position As the x1 and x2 values change the values of dy and m change automatically Change the x1 and x2 values by either e Dragging the rulers to the left and the right with the mouse or e Entering their values in the x1 and x2 edit boxes in the Rulers panel 5 41 5 Interactive Tools Using the Signal Browser Interactive Signal Analysis The Signal Browser tool is an interactive signal exploration environment It provides a graphical view of the signal object s currently selected in the Signals column of SPTool Using the Signal Browser you can e View and compare vector or array signals e Zoom in on a range of signal data to examine it more closely e Measure a variety of characteristics of signal data e Play signal data on audio hardware Opening the Signal Browser To open or activate the Signal Browser from SPTool 1 Click on oneor more signals in the Signals list of SPTool 2 Press View in the Signals panel of SPTool The Signal Browser is activated and the selected signal s are loaded into the Signal Browser and displayed Basic Signal Brows
228. e Equiripple FIR which accesses the toolbox function r emez to create an equiripple FIR filter e Least Squares FIR which accesses the toolbox function f i r s to create an FIR filter using the least square design method e Kaiser Window FIR which accesses thef i r 1 function tocreatean FIR filter using a Kaiser window Example FIR Filter Design Standard Band Configuration In the following example use the Kaiser window filter design option 1 Select Kaiser Window FIR as the filter design from the Algorithm pop up menu 2 Select bandpass from the Type pop up menu as the configuration 3 Set the filter s sampling frequency to 2000 Hz by entering this value in the Sampling Frequency text box 4 Click Apply to redraw the response with these settings NOTE This must be done before you change the following parameters 5 Check the Minimum Order check box to enable automatic order selection 5 63 5 Interactive Tools 5 64 6 Set Fp1to290 and Fp2to525 These fields respectively define the lower and upper passband edge frequencies in Hertz 7 Set Fs1to200 andFs2to625 These fields respectively define the lower and upper stopband edge frequencies in Hertz 8 Set Rp passband ripple to4 and Rs stopband attenuation to 30 Rp and Rs are specified in dB 9 Press the Apply button The Filter Designer callsf i r 1 to create the filter using a Kaiser window The Filter Designer updates the magnitude plot t
229. e complex signal that has x as its real part and the Hilbert transform of x as its imaginary part For this FIR method an alternative to the hi bert function you must delay x by half the filter order to create the analytic signal xd zeros 10 1 x l length x 10 delay 10 samples xa xd j xh analytic signal This method does not work directly for filters of odd order which requirea noninteger delay In this case thehi bert function described in the Specialized Transforms section in Chapter 4 estimates the analytic signal Alternately use theres amp e function to delay the signal by a noninteger number of samples Differentiators Differentiation of a signal in the time domain is equivalent to multiplication of the signal s F ourier transform by an imaginary ramp function That is to differentiate a signal pass it through a filter that has a response H w jw Approximate the ideal differentiator with a delay usingr emez orfirls with a d or differentiator option b remez 21 0 1 0 pi Fs d To obtain the correct derivative scale by pi Fs rad sec whereFs isthe sampling frequency in Hertz For a type lll filter the differentiation band should stop short of the Nyquist frequency and the amplitude vector must reflect that change to ensure the correct slope bb remez 20 0 9 0 9 pi Fs d Inthe d mode r emez weights the error by 1 w in nonzero amplitude bands to minimize the maxim
230. e filter yn filter h 1 xn HEST f tfe xn yn 256 Fs 256 128 none H freqz h 1 f Fs plot f abs H plot f abs HEST Actual Transfer Function Magnitude 1 T T T T T 0 8 0 6 0 4 0 2 L L L L 50 100 150 200 250 300 350 400 450 500 Frequency Hz Transfer Function Magnitude Estimate 1 T T T T T L L L L 0 50 100 150 200 250 300 350 400 450 500 Frequency Hz Coherence Function The magnitude squared coherence between two signals x n and y n is Po Cyy a poe Pox Pyy This quotient is a real number between 0 and 1 that measures the correlation between x n and y n at the frequency o 3 15 3 Statistical Signal Processing 3 16 Thecohere function takes sequences x andy computes their PSDs and CSD and returns the quotient of the magnitude squared of the CSD and the product of the PSDs Its options and operation aresimilar tothecsd andt fe functions The coherence function of xn and the filter output yn versus frequency is cohere xn yn 256 Fs 256 128 none Coherence Function BEBRE 50 1 00 1 50 200 250 300 Frequency o o 9 TES o 5 Coherence Function Estimate o o 500 If the input sequence length window length and overlap aresuch thatcoher e operates on only a single record the function returns all ones Multitaper Method The multitaper method MTM uses orthogonal windows or tapers t
231. e for the gain in the Gain field e For Second Order Sections you specify A variable name or a value for the SOS matrix in the SOS Matrix field e For every filter you specify A variable name or a value for the filter s sampling frequency in the Sampling Frequency field Importing a Spectrum When you import a spectrum you specify e A variablenameor a value for the power spectral density PSD of the signal in the PSD field e A variablenameor a value for the frequency vector in the Freq Vector field P hepe te SFT ol 5 13 5 Interactive Tools Working with Signals Filters and Spectra When a signal filter or spectrumis imported into SPT ool or created in SPTool itis displayed in the appropriate list box as shown below Using the Edit menu functions and SPTool buttons you can edit various properties of the data in SPTool and invoke all of SPTool s digital signal processing functions EJ SPTool saved spt AE x File Edit Help Window Signals Filters Spectra te Ee eee re Hami E filt copy design spect2 auto taping Peg E spect3 auto hellocopy vector hellocopy1 vector Signals list Filters list Spectra list i i f Signal View button View View Spectrum View button New Design Create Edit Design Update Apply Filter View button 5 14 Using SPTool Component Lists in SPTool Each signal filter and spectrum in SPTool is displayed in t
232. e linear time invariant transfer function Txy Vectors x andy must be the same length Txy tfe x y uses the following default values enfft min 256 length x e Fs 2 e window hanning nfft e noverlap 0 nfft specifies the FFT length that t fe uses This value determines the frequencies at which the power spectrum is estimated Fs is a scalar that specifies the sampling frequency wi ndow specifies a windowing function and the number of samples t f e uses in its sectioning of thex andy vectors noverlap is the number of samples by which the sections overlap Any arguments that omitted from the end of the parameter list use the default values shown above Ifx isreal tfe estimates the transfer function at positive frequencies only in this case the output Tx y is a column vector of length nf ft 2 1 fornfft even and nfft 1 2 forn odd Ifx ory is complex tf e estimates the transfer function for both positive and negative frequencies andTxy has length nf ft 6 311 tfe 6 312 Txy tfe x y nfft uses the specified FFT length nfft in estimating the transfer function Specify nf ft as a power of 2 for fastest execution Txy f tfe x y nfft Fs returns a vector f of frequencies at which t fe estimates thetransfer function Fs isthesampling frequency f isthesamesize asTxy soplot f Txy plots the transfer function estimate versus properly scaled frequency Fs has no effect on the output Txy it is a frequency scaling m
233. e satisfying the Levinson Durbin recursion These methods are listed in the table below together with the corresponding toolbox function name The number below each method name indicates the page that describes the method in greater 3 5 3 Statistical Signal Processing 3 6 detail See Parametric Modeling in Chapter 4 for details about pc and other parametric estimation functions Method Description Functions Burg Autoregressive AR spectral pburg 3 20 estimation of a time series by minimization of linear prediction errors Multitaper Spectral estimate from combination pmt m 3 16 of multiple orthogonal windows or tapers MUSIC Multiple signal classification or pmusic 3 22 eigenvector method Welch Averaged periodograms of psd csd 3 6 overlapped windowed signal sections tfe cohere Yule Walker AR Autoregressive AR spectral pyul ear 3 19 estimate of a time series from its estimated autocorrelation function Welch s Method One way of estimating the power spectrum of a process is to simply find the discrete time F ourier transform of the samples of the process usually done on a grid with an FFT and take the magnitude squared of the result An example 1001 element signal xn which consists of two sinusoids plus noise is given by Fs 1000 sampling frequency t 0 1 Fs 1 one second worth of samples xn sin 2 pi 50 t 2 sin 2 pi l20 t randn size t A crude estimate of t
234. e strictly less than the window length Requires positive integer values for NFFT and NOVERLAP Requires vector either row or column input Requires inputs X and Y to have the same length 6 67 cohere Algorithm cohere estimates the magnitude squared coherence function 1 using Welch s method of power spectrum estimation See references 2 and 3 as follows 1 It divides the signals x andy into overlapping sections detrends each section and multiplies each section by wi ndow 2 It calculates the length nf ft fast Fourier transform of each section 3 It averages the squares of the spectra of thex sections to formP xx averages the squares of the spectra of they sections to form Pyy and averages the products of the spectra of thex andy sections to formPxy It calculates Cx y by Cxy abs Pxy 2 Pxx Pyy See Also csd Estimate the cross spectral density CSD of two signals psd Estimate the power spectral density PSD of a signal using Welch s method tfe Transfer function estimate from input and output References 1 Kay S M Modern Spectral Estimation Englewood Cliffs NJ Prentice Hall 1988 Pg 454 2 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 3 Welch P D The Use of Fast F ourier Transform for the Estimation of Power Spectra A Method Based on Time Averaging Over Short Modified Periodograms IEEE Trans Audi
235. e the same length Requires confidence parameter to be a scalar between 0 and 1 cohere Estimate magnitude squared coherence function between two signals pourg Power spectrum estimate using the Burg method pmt m Power spectrum estimate using the multitaper method MTM pmusic Power spectrum estimate using MUSIC eigenvector method psd Estimate the power spectral density PSD of a signal using Welch s method pyul ear Power spectrum estimate using Yule Walker AR method tfe Transfer function estimate from input and output 6 87 csd References 6 88 1 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 414 419 2 Welch P D TheUseof Fast Fourier Transform for the Estimation of Power Spectra A Method Based on Time Averaging Over Short Modified Periodograms IEEE Trans Audio Electroacoust Vol AU 15 J une 1967 Pgs 70 73 3 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pg 737 czt Purpose Syntax Description Examples Chirp z transform y czt x mw a czt x iT y czt x m w a returns the chirp z transform of signal x The chirp z transform is the z transform of x along a spiral contour defined by w anda m is a scalar that specifies the length of the transform w is the ratio between points along the z plane spiral contour o
236. e the sinc function is l t 0 sinc t 4 sin 7t Tt t 0 This function is the continuous inverse F ourier transform of the rectangular pulse of width 27 and height 1 1 f7 sinc t Z Ha 2T T y sinc x returns an array y the same size as x whose elements are the sinc function of the elements of x Thespace of functions bandlimited in the frequency band e 2 2 is spanned by theinfinite yet countable set of sinc functions shifted by integers Thus any such bandlimited function g t can be reconstructed from its samples at integer spacings co g Y e n sincte n n oo 6 275 sinc Example Perform ideal bandlimited interpolation by assuming that the signal to be interpolated is 0 outside of the given timeinterval and that it has been sampled at exactly the Nyquist frequency t 1 10 a column vector of time samples randn seed 0 x randn size t a column vector of data ts is times at which to interpolate data ts linspace 5 15 600 y sinc ts ones size t t ones size ts x plot t x o ts y 2 6 276 sinc See Also chirp cos diric gauspuls pulstran rectpuls sawtooth sin Square tripuls Swept frequency cosine generator Cosine of vector matrix elements see the online MATLAB Function Reference Dirichlet or periodic sinc function Gaussian modulated sinusoidal pulse generator Pulse train generator
237. e windows Pxx f pmusic x corr forcesx to betaken as a correlation matrix In this case the arguments wi ndow and nover l ap are ignored Pxx f pmusic x ev selects the eigenvector variant of the MUSIC estimator See the Algorithm section below for an explanation of how this is different from the MUSIC method Pxx f evects svals pmusic x returnstwoadditional arguments evects iS a matrix of eigenvectors spanning the noise subspace one per column sval s is either a vector of singular values Squared fromsvd ora vector of eigenvalues of the correlation matrix when the corr option is present The input x can be a vector or a matrix x can be interpreted as signal data or as a correlation matrix in one of three ways e x isa vector of signal values row or column In this case the dimension of the eigenvectors must be given This is done either by taking the default value of 2 p or by specifying a window length using wi ndow e x is a rectangular m by n possibly square matrix In this case each column of x is a separate observation signal that enters into the SVD analysis n is 6 229 pmusic Examples 6 230 the number of observations and the dimension of the eigenvectors is equal to m the length of a column e x is a Square matrix and thetrailing corr is present x is treated asa correlation matrix In this case the matrix must have only real nonnegative eigenvalues Thei
238. e2 debug and Igri d options may be specified b delta cremez returns the maximum ripple height delta 6 79 cremez b delta opt cremez returnsastructureopt of optional results computed by cr emez and contains the following fields opt fgrid Frequency grid vector used for the filter design optimization opt des Desired frequency response for each point inopt fgrid opt wt Weighting for each point inopt fgrid opt H Actual frequency response for each point inopt fgrid opt error Error at each point inopt fgrid opt iextr Vector of indices intoopt fgrid for extremal frequencies opt fextr Vector of extremal frequencies Example Design a 31 tap linear phase lowpass filter b cremez 30 1 0 5 0 4 0 7 0 8 1 lowpass freqz b 1 512 whole degrees a Phase 6 80 Magnitude Response dB 50 1 0 5 1 1 5 2 Normalized frequency Nyquist 1 1000 F 2000 F 3000 F 4000 0 i 0 5 1 1 5 2 Normalized frequency Nyquist 1 cremez Remarks Algorithm User definable functions may be used instead of the predefined frequency response functions for fresp Thefunction is called from withincremez using the following syntax dh dw fresp n f gf w pl p2 where e n isthe filter order e f is the vector of frequency band edges that appear monotonically between land 1 where 1 is the Nyquist frequency gf is a vect
239. ear mt lb 14 1024 Fs 14th order model plot f 10 log10 P1 f 10 0g10 P2 legend Welch Yule Walker AR 20 Welch Yule Walker AR 104 Magnitude dB do D L O O oO oO T i A is T 50 i i i i i i i 0 500 1000 1500 2000 2500 3000 3500 4000 Frequency Hz Thesolid Yule Walker AR spectrum is smoother than the periodogram because of the simple underlying all pole model Burg Method The Burg method for AR spectral estimation is based on minimizing the forward and backward prediction errors while satisfying the Levinson Durbin recursion see Marple 2 Chapter 7 and Proakis 4 Section 12 3 3 In Spectral Analysis contrast to other AR estimation methods the Burg method avoids calculating the autocorrelation function and instead estimates the reflection coefficients directly The primary advantages of the Burg method are resolving closely spaced sinusoids in signals with low noiselevels and estimating short data records in which case the AR power spectral density estimates are very close to the true values In addition the Burg method ensures a stable AR model and is computationally efficient The accuracy of the Burg method is lower for high order models long data records and high signal to noise ratios which can cause line splitting or the generation of extraneous peaks in the spectrum estimate Thespectral density estimate computed by the Burg method is also suscep
240. ecause of the energy compaction mentioned above it is possible to reconstruct a signal from only a fraction of its DCT coefficients F or example generate a 10 Hz sinusoidal sequence sampled at 1000 Hz t 0 1 999 1 x sin 2 pi 25 t Compute the DCT of this sequence and reconstruct the signal using only those components with value greater than 53 12 of the original 1000 DCT coefficients y dct x compute DCT y2 find abs y lt 53 use 12 coefs y y2 zeros size y2 zero out points lt 53 z idct y reconstruct signal using inverse DCT Plot the original and reconstructed sequences plot t x plot t z axis 0 1 1 1 i Original Signal 0 5F J OF a 0 5 ar 0 4 0 2 03 0 4 05 0 6 07 08 0 9 il Reconstructed Signal a 0 oa T Oo T 0 oa T 1 ii 0 0 1 02 03 Ri 1 n 0 5 0 6 0 7 0 8 0 9 1 One measure of the accuracy of the reconstruction is norm x z norm x 4 36 Specialized Transforms that is the norm of the difference between the original and reconstructed signals divided by the norm of the original signal In this case the relative error of reconstruction is 0 1778 The reconstructed signal retains approximately 82 of the energy in the original signal Hilbert Transform The toolbox function hi bert computes the Hilbert transform for a real input sequence x and returns a complex result of the same leng
241. echo detection application First create a 45 Hz sine wave sampled at 100 Hz t 0 0 01 1 27 sl sin 2 pi 45 t Add an echo of the signal with half the amplitude 0 2 seconds after the beginning of the signal 2 sl 0 5 zeros 1 20 s1 1 108 4 23 4 Special Topics 4 24 The complex cepstrum of this new signal is c cceps s2 plot t c 1 N85 02 04 06 08 1 12 1 4 Note that the complex cepstrum shows a peak at 0 2 seconds indicating the echo The real ceostrum of a signal x sometimes called simply the cepstrum is calculated by determining the natural logarithm of magnitude of the F ourier transform of x then obtaining the inverse F ourier transform of the resulting sequence 2 1 7 Cx log 20 Jr The toolbox function r ceps performs this operation returning the real cepstrum for a sequence x The returned sequence is a real valued vector the same size as the input vector x e eJON agy y rceps x By definition you cannot reconstruct the original sequence from its real cepstrum transformation as the real cepstrum is based only on the magnitude of the Fourier transform for the sequence see 2 Ther ceps function C epstrum Analysis however can reconstruct a minimum phase version of the original sequence by applying a windowing function in the cepstral domain To obtain both the real cepstrum and the minimum phase reconstruction for a sequence use y
242. ecifies the delay to each pulse repetition in column 1 and an optional attenuation for each repetition in column 2 The pulse train is constructed by passing the name of the gaus pul s function topul stran along with additional parameters that specify a 10 kHz Gaussian pulse with 50 bandwidth T 0 1 50E3 10E 3 D 0 1 1E3 10E 3 0 8 0 10 Y pulstran T D gauspuls 10E3 0 5 plot T Y 1 T 0 87 4 0 67 4 Ht 0 2 4 0 4 J 0 6 4 0 8 n 1 1 n 1 n n n n 0 0 001 0 002 0 003 0 004 0 005 0 006 0 007 0 008 0 009 0 01 The Sinc Function Thesi nc function computes the mathematical sinc function for an input vector or matrix x The sinc function is the continuous inverse Fourier transform of the rectangular pulse of width 2x and height 1 W aveform G eneration Time Vectors and Sinusoids _ 1 jot sinc t AiG da The sinc function has a value of 1 wherex is zero and a value of sin 7x TX for all other elements of x To plot the sinc function for a linearly spaced vector with values ranging from 5to5 x linspace 5 5 y sinc x plot x y 1 0 8 0 6 0 4 0 2 0 2 0 4 1 1 1 1 ji 1 1 i 5 A 1 11 1 Signal Processing Basics 1 12 The Dirichlet Function The toolbox function di ri c computes the Dirichlet function sometimes called the periodic sinc or aliased sinc function for an input vec
243. ectangular window chebwin Chebyshev window hamming Hamming window kaiser Kaiser window triang Triangular window 1 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 6 169 hilbert Purpose Syntax Description Algorithm 6 170 Hilbert transform y hilbert x y hilbert x returns a complex helical sequence sometimes called the analytic signal from a real data sequence The analytic signal has a real part which is the original data and an imaginary part which contains the Hilbert transform The imaginary part is a version of the original real sequence with a 90 phase shift Sines are therefore transformed to cosines and vice versa The Hilbert transformed series has the same amplitude and frequency content as the original real data and includes phase information that depends on the phase of the original data Ifx isamatrix y hil bert x operates columnwise on the matrix finding the Hilbert transform of each column The Hilbert transform is useful in calculating instantaneous attributes of a time series especially the amplitude and frequency The instantaneous amplitude is the amplitude of the complex Hilbert transform the instantaneous frequency is the time rate of change of the instantaneous phase angle For a pure sinusoid the instantaneous amplitude and frequency are constant The instantaneous phase however is a sawtooth reflecting the w
244. ectively while the hil bert and differentiator flags produce type III n even and IV n odd filters The various filter types have different symmetries and constraints on their frequency responses see 2 for details Linear Phase Filter Response H f Response H f Filter type Order n Symmetry of Coefficients f 0 f 1 Nyquist Type Even even No restriction No restriction Type II Odd b k b n 2 k k 1 n 1 Norestriction H 1 0 Type III Even odd H 0 0 H 1 0 Type lV Odd b k b n 2 k k 1 n 1 H 0 0 No restriction Diagnostics An appropriate diagnostic message is displayed when incorrect arguments are used F must be even length F and A must be equal lengths Requires symmetry to be hilbert or differentiator Requires one weight per band Frequencies in F must be nondecreasing Frequencies in F must be in range 0 1 A more serious warning message is Warning Matrix is close to singular or badly scaled This tends to happen when the filter length times the transition width grows large In this case thefilter coefficients b might not represent the desired filter You can check the filter by looking at its frequency response 6 153 firls See Also References 6 154 firl Window based finite impulse response filter design standard response fir2 Window based finite impulse response filter design arbitrary response firrcos Raised cosine FIR filter desig
245. ectrum select exactly one signal and one spectrum in SPT ool and press Update Press Apply in the Spectrum Viewer The spectrum is updated to reflect the data in the currently selected signal 5 88 Using the Spectrum Viewer Interactive PSD Analysis Basic Spectrum Viewer Functions The Spectrum Viewer window has the following components e A Parameters panel for viewing and modifying the parameters or method of the current spectrum e A signal identification panel that displays information about the signal linked to the current spectrum A main axes display area for viewing spectra graphically Zoom controls for getting a closer look at spectral features Rulers and line display controls for making spectral measurements and comparisons e Spectrum management controls Inherit from Revert and Apply Menu options for modifying plot display characteristics Ruler and line display controls E Spectrum Viewer AE E Fie Options Window ae Zoom controls neist Zoom sect i A Signal mtlb Signal ID 4001 by 1 real i i Fs 7418 Nertical Horizontal Parameters panel p anaes ag ethod Wech J 1 1238 748 Nft 1024 y1 16 13184 Nwind 256 i em Window hanning x 2470 252 Main axes area y2 16 817501 Overlap 0 dx 1231 5039 Detrending none a 4 dy 0 68566151 Scaling Unbiased I Cont Int El iss ye Inherit from E oo P 3000 Save Rulers Frequency
246. ecution time using chirp z transform 4 34 inverse 1 43 6 175 matrix 6 102 two dimensional 1 45 6 176 matrix 6 102 two dimensional 1 45 6 126 See also fast Fourier transform FFT ff t discrete prolate spheroidal sequences DPSSs 3 19 discrete time F ourier transform 3 5 discretization 2 41 6 177 bilinear transformation 2 42 prewar ping 2 43 impulse invariance 2 41 disk loading variables from 5 9 dpss 6 8 6 104 dpss mat 3 19 dpssclear 3 19 6 8 6 106 dpssdir 3 19 6 8 6 107 dpssload 3 19 6 8 6 108 Index DPSSs Seediscrete prolate spheroidal sequences dpsssave 3 19 6 8 6 109 duty cycle specifying 1 8 E echo detection 4 23 edge effects 1 22 edge frequencies setting in Filter Designer 5 62 Edit Design button 5 18 5 56 eig inpmusic function 3 24 eigenanalysis defined 3 23 frequency estimator functions 3 23 eigenvector method 3 5 3 22 See also multiple signal classification method ellip 2 5 2 6 6 4 6 110 accessing from Filter Designer 5 55 ellipap 2 5 6 9 6 116 example 2 10 ellipord 2 5 6 5 6 117 elliptic filter analog 6 111 analog prototype 2 38 6 116 bandpass configuration analog 6 112 digital 6 110 bandstop configuration analog 6 112 digital 6 111 characteristics 2 10 design 6 110 digital 6 110 highpass configuration analog 6 112 digital 6 111 limitations 6 114 lowpass configuration analog 6 111 digital 6 110 order estimation 2 7 6 117 energy compaction 4 36 equiripple charact
247. elected Mpls Racing Oa a2 ba Frequency Zara amp Poba You can experiment to find the tiling option that works best for each specific combination and number of subplots You can zoom in on a subplot by clicking on Mouse Zoom and then clicking on or dragging over a selected area of the subplot By default mouse zooming in the Filter Viewer is not persistent after you click once the zoom mode is turned off You can make zooming persistent by checking Stay in Zoom mode after Zoom in the SPT ool Preferences dialog box This allows you to click repeatedly in a subplot to continue to zoom in on a particular feature of the display 5 79 5 Interactive Tools 5 80 After you zoom in on a subplot you can click and drag to pan around the subplot 1 Click on Mouse Zoom to turn on mouse zoom mode 2 Click on a feature of a subplot to zoom in on it 3 If persistent zooming is enabled click on Mouse Zoom again to turn off mouse zoom mode 4 Click again in thesame subplot hold down the mouse button until the hand cursor is displayed and drag the mouse to pan around the subplot Viewing Filter Plots This section has a brief description and picture of each of the six filter response plots available in the Filter Viewer A sequence of connected examples shows you how to display each plot on its own you can also display any combination of plots as needed Each plot in the example sequence displays the response of an or
248. en incorrect arguments are used Order cannot be less than zero Sampling must be either symmetric or periodic A warning message is displayed for noninteger n Warning Rounding order to nearest integer bartlett Bartlett window blackman Blackman window boxcar Rectangular window chebwin Chebyshev window hanning Hanning window kaiser Kaiser window triang Triangular window 1 Oppenheim A V and R W Schafer Discre amp teTime Signal Processing Englewood Cliffs NJ Prentice Hall 1989 hanning Purpose Syntax Description Diagnostics See Also References Hanning window w hanning n w hanning n sflag w hanning n returns ann point symmetrically sampled Hanning window in the column vector w n should be a nonnegative integer The coefficients of a Hanning window are vin 05 cos 21 k 1 n n 1 w hanning n sflag returnsann point Hanning window using the window sampling specified by sf ag which can be either periodic or symmet ric the default When peri odic is specified hanni ng computes a length n 1 window and returns the first n points An error message is displayed when incorrect arguments are used Order cannot be less than zero Sampling must be either symmetric or periodic A warning message is displayed for noninteger n Warning Rounding order to nearest integer bartlett Bartlett window blackman Blackman window boxcar R
249. ency and amplitude vectors An example FIR Filter Design lowpass equiripple filter with 10 times less ripple in the stopband than the passband is n 20 filter order f 0 4 5 1 frequency band edges a l 1 0 0 desired amplitudes w 1 10 weight vector b remez n f a w A legal weight vector is always half the length of thef anda vectors there must be exactly one weight per band Anti Symmetric Filters Hilbert Transformers When called with atrailing h or Hilbert option remez andfirls design FIR filters with odd symmetry that is type III for even order or type IV for odd order linear phase filters An ideal Hilbert transformer has this anti symmetry property and an amplitude of 1 across the entire frequency range Try the following approximate Hilbert transformers b remez 21 05 1 1 1 h highpass Hil bert bb remez 20 05 95 1 1 h bandpass Hil bert Highpass Hilbert Bandpass Hilbert 1 1 0 8 0 8 0 6 0 6 0 4 0 4 0 2 0 2 0 25 0 5 0 75 1 0 25 0 5 0 75 1 Frequency Normalized Frequency Normalized You can find the delayed Hilbert transform of a signal x by passing it through these filters Fs 1000 sampling frequency Pe Oe ERs 2 0 two second time vector x sin 2 pi 300 t 300 Hz sine wave example signal xh filter bb 1 x Hilbert transform of x 2 25 2 Filter Design 2 26 The analytic signal corresponding tox is th
250. ensional fast Fourier transform fftshift Rearrange the outputs of fft andfft2 ifft One dimensional inverse fast Fourier transform ifft2 Two dimensional inverse fast Fourier transform fftfilt Purpose Syntax Description Example Algorithm FFT based FIR filtering using the overlap add method y fftfilt b x y fftfilt b x n fftfilt filters data using the efficient FF T based method of overlap add a frequency domain filtering technique that works only for FIR filters y fftfilt b x filters the data in vector x with the filter described by coefficient vector b It returns the data vector y The operation performed by fftfilt is described in the time domain by the difference equation y n b 1 x n b 2 x n 1 b nb 1 x n nb An equivalent representation is the z transform or frequency domain description z b0 bQ z 1 b nb 1 z X 2 By default f f t fi lt chooses an FFT length and data block length that guarantee efficient execution time y fftfilt b x n UsesanFFT length ofnf ft 2 nextpow2 n and a data block length of nfft length b 1 fftfilt works for both real and complex inputs Show that the results fromfftfilt andfilter areidentical b 12 3 4 x 1 zeros 1 99 normfftfilt b x filter b 1 x ans 9 5914e 15 fftfilt usesfft toimplement the overlap add method 1 a technique that combines successive frequency domain filtered blocks of a
251. ensions Each dimension of the output matrix C is equal in size to the sum of the corresponding dimensions of the input matrices minus 1 For ma na size A and mb nb size B thensize C ma mb 1 natnb 1 C conv2 A B shape returns a subsection of the two dimensional convolution with size specified by shape where e full returns the full two dimensional convolution default e same returns the central part of the convolution that is the same size as A e valid returns only those parts of the convolution that are computed without the zero padded edges Using this option si ze C ma mb 1 na nb 1 when si ze A gt size B conv2 executes most quickly when si ze A gt size B In image processing the Sobel edge finding operation is a two dimensional convolution of an input array with the special matrix s 12 1 00 0 1 2 1 Given any image the following line extracts the horizontal edges h conv2 l s The lines below extract first the vertical edges then both horizontal and vertical edges combined v conv2 1 s v2 sgrt h 2 v 2 conv2 See Also conv convn deconv filter2 xcorr xcorr2 Convolution and polynomial multiplication N dimensional convolution see the online MATLAB Function Reference Deconvolution and polynomial division Two dimensional digital filtering Cross correlation function estimate Two dimensional cross correlation 6 71 convmtX amp
252. er y t modulate x Fc Fs method opt Thedemod function performs denodulation that is it obtains the original message signal from the modulated signal The syntax for demod is x demod y Fc Fs method opt demod uses any of the methods shown for modul at e but the syntax for quadrature amplitude demodulation requires two output parameters X1 X2 demod y Fc Fs qam If the input y is an array demod demodulates all columns 4 29 4 Special Topics Try modulating and demodulating a signal A 50 Hz sine wave sampled at 1000 Hzis t 0 1 1000 2 x sin 2 pi 50 t With a carrier frequency of 200 Hz the modulated and demodulated versions of this signal are y modulate x 200 1000 am z demod y 200 1000 am To plot portions of the original modulated and demodulated signal plot t 1 150 x 1 150 plot t 1 150 y 1 150 plot t 1 150 2 1 150 Original Signal Modulated Signal 1 ll 2 0 5 1 0 0 0 5 1 1 2 0 0 05 0 1 0 15 0 0 05 0 1 0 15 Demodulated Signal 1 0 5 0 0 5 1 0 0 05 0 1 Thevoltage controlled oscillator function vco creates a signal that oscillates at a frequency determined by the input vector The basic syntax for vco is y vco x Fc Fs whereFc is the carrier frequency and Fs is the sampling frequency 4 30 Communications Applications To scale the frequency modulation range y vco x F
253. er Functions The Signal Browser has the following components e A main axes display area for viewing signals graphically e Display management controls Array Signals and the complex signal display pop up menu e Zoom controls for getting a closer look at signal features e Rulers and line display controls for making signal measurements and comparisons e A panner for seeing what part of the signal is currently being displayed and quickly moving the view to other features of the signal e A menu option for playing a selected signal through audio equipment 5 42 Using the Signal Browser Interactive Signal Analysis Display management controls Viewing zoom controls Measuring line and ruler controls EJ Signal Browser Selection _ e J coo Rulers Main axes da Horizontal display area Es T x1 017969803 y1 1 3435103 x2 035953087 y2 0 38842729 dx 0 17983284 dy 1 7319376 Save Rulers Panner Panner Menus File Menu Use Close from the File menu to close the Signal Browser All signal selection and ruler information will be lost Settings you changed and saved using the Preferences window in SPTool are saved and used the next time you open a Signal Browser Fn ESD ere Options Menu Use Play from the Options menu to play the selected signal Play only works when you have sound capabilities on your computer If your computer does not have sound c
254. er design function 2 11 2 Filter Design 2 12 Bessel filters generally require a higher filter order than other filters for satisfactory stopband attenuation H jQ lt 1 2 at Q 1 and decreases as n increases i 0 8 Magnitude oO D T o a T 0 2 0 f 10 10 10 Frequency rad sec NOTE The lowpass filters shown above were created with the analog prototype functions besselap buttap cheblap cheb2ap andel i pap These functions find the zeros poles and gain of an order n analog filter of the appropriate type with cutoff frequency of 1 rad sec The complete filter design functions besself butter chebyl cheby2 andel lip call the prototyping functions as a first step in the design process See Special Topics in IIR Filter Design on page 2 37 for details To create similar plots usen 5 and as needed Rp 0 5 andRs 20 For example to create the elliptic filter plot z p k ellipap 5 5 20 w logspace 1 1 1000 h freqs k poly z poly p w semi logx w abs h grid IIR Filter Design Direct IIR Filter Design This toolbox uses the term direct methods to describe techniques for IIR design that find a filter based on specifications in the discrete domain Unlike the analog prototyping method direct design methods are not constrained to the standard lowpass highpass bandpass or bandstop configurations Rather these functions design filters with an arbitr
255. er to 1 rad sec for low or highpass filters or to 1 and 1 rad sec for bandpass or bandstop filters It then computes the minimum order required for a lowpass filter to meet the stopband specification buttord Butterworth filter order selection chebyl Chebyshev type I filter design passband ripple cheb2ord Chebyshev type II filter order selection ellipord Elliptic filter order selection kaiserord Estimate parameters for an FIR filter design with Kaiser window 1 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pg 241 cheb2ap Purpose Chebyshev type II analog lowpass filter prototype Syntax z p k cheb2ap n Rs Description z p k cheb2ap n Rs finds the zeros poles and gain of an order n Chebyshev type II analog lowpass filter prototype with stopband rippleRs dB down from the passband peak value cheb2ap returns the zeros and poles in length n column vectorsz andp andthe gain in scalar k Ifn is odd z is length n 1 The transfer function is zls _ s zs 2 2 s 2 P s s POs p 2 s p n Chebyshev type II filters are monotonic in the passband and equiripplein the stopband The pole locations are the inverse of the pole locations of cheblap whose poles are evenly spaced about an ellipse in the left half plane The Chebyshev type II cutoff frequency wg is set to 1 for a normalized result This is the frequency
256. er typical choices are 2 5 2 3 7 2 The number of sequences used to form Pxx is2 nw 1 Pxx pmtm x nw nfft defines the frequency grid as length nf f t When x is real Pxx islength nfft 2 1 fornfft evenand nfft 1 2 fornfft odd when x is complex Pxx is length nf f t The default for nf ft is 256 or the next power of 2 greater than the length of x whichever is larger Pxx f pmtm x nw nfft Fs returnsf the vector of frequencies at which the PSD is estimated for the sampling frequency Fs The default for Fs is 2 Hz Pxx f pmtm x nw nfft Fs method specifies the algorithm used for combining the individual spectral estimates where method is e adapt to specify Thomson s adaptive nonlinear combination default e unity to specify a linear combination with unity weights e ei gen to specify a linear combination with eigenvalue weights Pxx Pxxc f pmtm x nw nfft Fs method returnsPxxc the 95 confidence interval for P xx and pmtm Remarks Pxx Pxxc f pmtm x nw nfft Fs method p returnsPxxc thep 100 confidence interval for Pxx wherep is a scalar between 0 and 1 Confidence intervals are computed using a chi squared approach wherePxxc 1 isthe lower bound and Pxxc 2 is the upper bound of the confidence interval Pxx Pxxc f pmtm x e v nfft Fs method p returns the PSD estimate xx the confidence interval Px xc and the frequency vector f fromthe data tapers ine and their concen
257. er with sidelobe height dB use the following B 0 1102 a 8 7 a gt 50 B 40 5842 a 21 4 0 07886 a 21 5020221 0 a lt 21 Increasing bet a widens the mainlobe and decreases the amplitude of the sidelobes increases the attenuation bartlett Bartlett window blackman Blackman window boxcar Rectangular window chebwin Chebyshev window hammi ng Hamming window hanni ng Hanning window kaiserord Estimate parameters for f i r1 with Kaiser window triang Triangular window 1 Kaiser J F Nonrecursive Digital Filter Design Using the Ig sinh Window Function Proc 19741EEE Symp Circuits and Syst April 1974 Pgs 20 23 2 IEEE Digital Signal Processing Il IEEE Press New York J ohn Wiley amp Sons 1975 6 193 kaiserord Purpose Syntax Description 6 194 Estimate parameters for an FIR filter design with Kaiser window n Wn beta ftype kaiserord f a dev n Wn beta ftype kaiserord f a dev Fs c kaiserord f a dev Fs cell kaiserord returns a filter order n andbet a parameter to specify a Kaiser window for use with thef i r1 function Given a set of specifications in the frequency domain kai serord estimates the minimum FIR filter order that will approximately meet the specifications kai ser or d converts the given filter specifications into passband and stopband ripples and converts cutoff frequencies into the form needed for windowed FIR filter design
258. eractive tools 5 2 extended example 5 100 Filter Designer 5 2 5 55 6 290 Filter Viewer 5 2 5 74 6 291 Signal Browser 5 2 5 42 6 289 Index Spectrum Viewer 5 3 5 88 6 292 SPTool 5 2 6 289 interp 6 9 6182 interpolation 6 182 FIR filter design 6 184 intfilt 6 5 6 184 inverse complex cepstrum 4 25 inverse discrete cosine transform 6 173 accuracy of signal reconstruction 4 37 inverse discrete F ourier transform 1 43 6 175 ifft 1 43 matrix 6 102 two dimensional 1 45 6 176 inverse filter design 6 190 6 237 analog 6 186 digital 6 190 inverse Fourier transform continuous Sees i nc function invfreqs 2 5 4 10 4 16 6 8 6 186 invfreqz 2 5 4 10 4 16 6 8 6 190 K kaiser 4 2 6 7 6193 accessing from Filter Designer 5 55 5 63 example 4 5 Kaiser window 4 4 6 193 and FIR filter design 4 7 5 63 beta parameter 4 4 6 193 example 4 5 frequency response 4 6 kai serord 2 17 6 5 6194 accessing from Filter Designer 5 65 L ladder coefficients 1 38 Lagrange interpolation filter 6 184 Laplace transform 1 41 equivalent to state space representation 1 41 latc2tf 1 39 1 42 6 3 6 199 latcfilt 1 39 6 3 6 200 lattice coefficients 1 38 lattice filter 1 42 implementation 1 38 implementation with atcfilt 1 39 lattice structure 1 37 lattice ladder filter implementation 1 38 implementation with atcfilt 1 39 least squares method FIR filter design 6 150 filter characteristics 6 153 levi nson 4 10 6 8 6 201 and para
259. erator tripuls Sampled aperiodic triangle generator 6 247 pyulear Purpose Syntax Description 6 248 Power spectrum estimate using Yule Walker AR method Pxx freqg pyulear x p Pxx freg pyulear x p nfft Fs corr Pxx freg a pyulear x p nfft Fs corr pyulear pyul ear estimates the power spectral density PSD of the signal vector x n or correlation matrix R using the Yule Walker AR method It derives an all pole model to represent the spectrum so the correct choice of the model order p is crucial Pxx freq pyulear x p returnsPxx the power spectrum estimate and freq a vector of frequencies at which the PSD was estimated x is the input signal or the input correlation matrix where e A row or column vector represents one signal e A square Hermitian symmetric matrix represents a correlation matrix when corr is used e A rectangular array assumes that each column of x is a separate look at the signal as in array processing p is the model order for the all pole filter Pxx freq pyulear x p nfft Fs corr specifies the FFT length nf ft default is 256 and the sampling frequency for thesignal Fs default is 2 If F s is specified the output frequency vector f r eq is scaled by this value If the input signal is real valued f r eq ranges from 0 toFs 2 1f the input signal is complex f req ranges from0 toFs corr isa text string to specify a correlation option
260. eristics Chebyshev type filter passband 2 9 Chebyshev type II filter stopband 2 10 Chebyshev window 4 9 elliptic filter 2 10 6 110 6 116 from Parks McClellan design 6 255 equiripple filter 2 22 error minimization between desired and actual response 2 22 for equiripple filter 5 65 for least squares filter 5 65 integral of square 2 22 minimax 2 22 weighting in frequency bands 2 24 estimation cross spectrum 3 13 power spectrum 3 6 transfer function 3 14 See also parametric modeling estimation methods in Spectrum Viewer 5 93 5 94 nonparametric FFT method 5 95 multiple signal classification method MU SIC 3 5 5 96 multitaper method MTM 3 5 5 95 Welch s method 3 5 5 97 Index parametric 3 5 Burg method 5 95 Yule AR method 5 97 Export menu item 5 7 exporting data from MATLAB 1 13 extensions to SPTool 5 29 F Factory Settings button in Preferences dialog box 5 29 fast Fourier transform FFT 1 22 1 43 and frequency response 1 24 fft function 1 22 prime factor algorithm 1 45 6 124 radix 2 algorithm 1 45 6 124 rolein signal processing 1 43 two dimensional 6 126 FFT 4 26 fft 1 2 1 22 1 43 6 6 6 122 complex inputs 1 45 example 1 44 execution time 1 45 6 125 prime factor algorithm 1 45 6 124 radix 2 algorithm 1 45 6 124 real inputs 1 45 rearranging output 1 45 6 129 specifying number of points 1 44 FFT length in Filter Designer 5 21 5 28 in Filter Viewer 5 26 FFT Length edit box in Preferences
261. ersion ratiop q d gcd 48000 44100 p 48000 d q 44100 d where we find that p 160 and q 147 Sample rate conversion is then accomplished byy upfirdn x h p q This cascade of operations is implemented in an efficient manner using polyphase filtering techniques and it is a central concept of multirate filtering see reference 1 for details on multirate filter theory Note that the quality of the resampling result relies on the quality of the FIR filter h Filter banks may be implemented using upfirdn by allowing the filter h to be a matrix with one FIR filter per column A signal vector is passed independently through each FIR filter resulting in a matrix of output signals 1 19 1 Signal Processing Basics 1 20 Anti Causal Zero Phase Filter Implementation In the case of FIR filters it is possible to design linear phase filters that when applied to data usingfi lter or conv simply delay the output by a fixed number of samples For IR filters however the phase distortion is usually highly nonlinear Thefi tfilt function uses the information in the signal at points before and after the current point in essence looking into the future to eliminate phase distortion Toseehowfiltfilt does this recall that if the z transform of a real sequence x n is X z the z transform of the time reversed sequence x n is X 1 z Consider the processing scheme X z X 2 H 1 2 H 2 X 2 H 2 X H X 1 2
262. es amp e uses is proportional ton larger values of n provide better accuracy at the expense of more computation time The default for n is 10 If youletn 0 resample performs a nearest neighbor interpolation y k x round k 1 q p 1 wherey k 0 if the index tox is greater than engt h x y resample x p q n beta usesbeta as the design parameter for the Kaiser window that r esampl e employs in designing the lowpass filter The default for bet a is 5 y resample x p q b filtersx with b a vector of filter coefficients y b resample x p q returns the vector b which contains the coefficients of the filter applied tox during the resampling process 6 267 resample Examples Resamplea simple linear sequence at 3 2 the original rate Fsl 10 original sampling frequency in Hz tl 0 1 Fs1 1 time vector x tl define a linear sequence y resample x 3 2 now resample it t2 0 length y 1 2 3 Fsl new time vector ph otGt lyst Peake yet oO S0e5t0 01e T6530 bey Obs Leb 4 legend original resampled 1 5 original 1b o resampled g 0 8 O lal 0 5 J CJ x o S ye O OF 0 1 1 1 35 0 0 5 1 1 5 time Notice that the last few points of the output y are inaccurate In its filtering process r esampl e assumes the samples at times before and after the given samples in x are equal to zero Thus large deviations from zero at the e
263. es the filter order n If the filter does not appear to meet the given specifications using Minimum Order order selection deselect Minimum Order and manually specify a slightly larger order n 1 orn 2 All of the FIR filter design options in the Filter Designer require an even filter order for the highpass and bandstop configurations For more information on order selection with the FIR filter design options see the reference descriptions ofremez remezord kaiserord firls andfiri in Chapter 6 5 65 5 Interactive Tools 5 66 Designing Infinite Impulse Response IIR Filters The Filter Designer lets you design a number of classical IIR filters including Butterworth Chebyshev type I Chebyshev type II and elliptic filters Example Classical IIR Filter Design In the following example design a simple Chebyshev type filter 1 Select Chebyshev Type IIR as the filter design from the Algorithm pop up menu Select highpass from the Type menu as the configuration Set the filter s sample frequency to 2000 Hz by entering this value in the Sampling Frequency text box Click Apply to redraw the response with these settings NOTE This must be done before you change the following parameters Check the Minimum Order check box Set Fp passband edge frequency to 800 and Fs stopband edge frequency to700 Fp and Fs are specified in Hertz Set Rp passband ripple to2 5 and Rs stopband attenuation to35 Rp
264. es the signal s name size data type real orcomp ex and sampling frequency To change any of these signal properties use SPT ool To associate a completely new signal with a displayed spectrum select the signal in SPTool and click Update in the Spectra panel Using the Spectrum Viewer Interactive PSD Analysis Spectrum Management Buttons Inherit from Choose a spectrum from this menu to let the active spectrum inherit its parameters not including the associated signal Click on Inherit from and drag to select the spectrum from which you want to inherit parameters Revert Restores the properties of the current spectrum to what they were the last time Apply was pressed Apply Compute and display the active spectrum using the parameters set in the Parameters panel Zoom Controls The available zoom controls in the Spectrum Viewer are Mouse Zoom Full View Zoom In Y Zoom Out Y Zoom In X and Zoom Out X See Zoom Controls on page 5 30 for details on using the zoom controls in the Spectrum Viewer Ruler and Line Display Controls Using the rulers and line display controls you can measure a variety of characteristics of spectra in the Spectrum Viewer See Ruler Controls on page 5 32 for details on using rulers and modifying line displays in the Spectrum Viewer Help Button To use context sensitive help click on the Help button The mouse pointer becomes an arrow with a question mark symbol Y ou can
265. escribed time domain impulse response It has applications in filter design exponential signal modeling and system identification parametric modeling b a prony h nb na findsa filter with numerator order nb denominator order na and the time domain impulse response inh pr ony returns the filter coefficients in row vectors b anda oflengthnb 1 andna 1 respectively The filter coefficients are in descending powers of z _ BR _ b 1 b 2 z7 et b nb 127 H L A z a 1 a 2 z7 a na 1 z Recover the coefficients of a Butterworth filter from its impulse response b a butter 4 0 2 b 0 0048 0 0193 0 0289 0 0193 0 0048 1 0000 2 3695 2 3140 1 0547 0 1874 h filter b a 1 zeros 1 25 bb aa prony h 4 4 bb 0 0048 0 0193 0 0289 0 0193 0 0048 ab 1 0000 2 3695 2 3140 1 0547 0 1874 prony implements the method described in reference 1 This method uses a variation of the covariance method of AR modeling to find the denominator coefficients a and then finds the numerator coefficients b for which the impulse response of the output filter matches exactly thefirstnb 1 samples of x The 6 237 prony filter is not necessarily stable but potentially can recover the coefficients exactly if the data sequence is truly an autoregressive moving average ARMA process of the correct order See Also butter Butterworth analog and digital filter design chebyl Chebyshev type I filter
266. example of using the GUI based interactive tools to design and implement an FIR digital filter apply it to a signal and display signals and spectra The steps include e Importing and naming a signal using SPTool e Designing a filter using the Filter Designer e In SPTool applying the filter to the signal to create another signal e Viewing the time domain information of the original and filtered signals using the Signal Browser e Comparing the spectra of both signals using the Spectrum Viewer 5 100 Example Generation of Bandlimited N oise Create Import and Name a Signal You can import an existing signal into SPTool or you can create a new signal and edit and name it in SPTool In this step you ll create a new signal at the command line and then import it into SPTool 1 At the command line create a random signal by typing x randn 5000 1 2 Activate SPTool by typing sptool The SPTool window is displayed 3 Select Import from the File menu The Import to SPTool window is displayed Notice that the variablex is displayed in the Workspace Contents list If itis not click the From Workspace radio button to display the contents of the workspace 4 Namethesignal and import it into SPTool a Makesure that Signal is selected in the Import As pop up menu b Click in the Data field and typex 5 101 5 Interactive Tools 5 102 You can also move the variablex into the Data field by d
267. f the following error messages P cannot be empty Second input must have only 1 or 2 elements P must be an integer Second input must contain non negative entries If the value of p is too large with respect to the eigenvector dimension and thresh islessthan 1 noeigenvectors can be assigned tothe noise subspace and the algorithm fails In this case pmusi c gives the following error message Noise subspace dimension cannot be zero If the corr parameter is used then the first input must be a square correlation matrix If it is not pmusic gives the following error message Correlation matrix R is not square The correlation matrix is then checked for validity if it fails pmusic gives the following error message Correlation matrix R has negative or complex eigenvalue Ipc Linear prediction coefficients pburg Power spectrum estimate using the Burg method pmt m Power spectrum estimate using the multitaper method MTM prony Prony s method for time domain IHR filter design psd Estimate the power spectral density PSD of a signal using Welch s method pyulear Power spectrum estimate using Yule Walker AR method 1 Schmidt R O Multiple Emitter Location and Signal Parameter Estimation IEEE Trans Antennas Propagation Vol AP 34 March 1986 Pgs 276 280 2 Marple S L Digital Spectral Analysis Englewood Cliffs NJ Prentice Hall 1987 Pgs 373 378 6 233 poly2rc Purpose Synt
268. f frequency of 300 Hz b a cheby1 9 0 5 300 500 6 53 cheby1 The frequency response of the filter is freqz b a 512 1000 n 9 Chebyshev Type Lowpass Filter t o L Magnitude Response dB N o Q o s T f f 300 fi fi L fi L fi fi fi L 0 50 100 150 200 250 300 350 400 450 500 Frequency Hertz Phase degrees 1000 L L L fi L L L i 0 50 100 150 200 250 300 350 400 450 500 Frequency Hertz Design a 10th order bandpass Chebyshev type filter with a passband from 100 to 200 Hz and plot its impulse response n 10 Rp 0 5 100 200 500 b a chebyl n Rp Wn y t impz b a 101 stem t y Impulse Response of n 10 Chebyshev Type Filter UL Jis Blatni 6 54 cheby1 Limitations Algorithm See Also For high order filters the state space form is the most numerically accurate followed by the zero pole gain form The transfer function form is the least accurate numerical problems can arise for filter orders as low as 15 cheby1 uses a five step algorithm 1 It finds the lowpass analog prototype poles zeros and gain using the cheblap function 2 It converts the poles zeros and gain into state space form 3 Ittransforms thelowpass filter into a bandpass highpass or bandstop filter with desired cutoff frequencies using a state space transformation For digital filter design cheby1 usesbilinear t
269. f interest and scalar a is the complex starting point on that contour The contour a spiral or chirp in thez plane is given by z a w 0 m1 czt x uses the following default values y em length x ewe exp j 2 pi m ea 1 With these defaults czt returns the z transform of x at m equally spaced points around the unit circle This is equivalent to the discrete F ourier transform of x orfft x Theempty matrix specifies the default value for a parameter Ifx isa matrix czt x m w a transforms the columns of x Create a random vector x of length 1013 and compute its DFT usingczt This is faster than thef f t function on the same sequence x randn 1013 1 y czt x Useczt to zoom in on a narrow band section 100 to 150 Hz of a filter s frequency response First design the filter h firl 30 125 500 boxcar 31 filter 6 89 czt Establish frequency and CZT parameters Fs 1000 fl 100 f2 150 in Hertz m 1024 w exp j 2 pi f2 f1 m Fs a exp j 2 pi f1 Fs Compute both the DFT and CZT of the filter y fft h 1000 z czt h m w a Create frequency vectors and compare the results fy O length y 1 1000 length y fz O length z 1 f2 fl length z f1 plot fy 1 500 abs y 1 500 axis 1 500 0 1 2 plot fz abs z axis fl f2 0 1 2 FFT CZT 1 0 8 0 8 0 6 0 6 0 4 0 4 0 2 0 2 Senee 0 100 200 300 400 50
270. fault value for any input argument except x or y For example Cxy cohere x y kaiser 128 5 uses 256 as the value for nf ft and 2 as the value for Fs Cxy cohere x y dflag specifies a detrend option where df ag is e i near toremovethe best straight line fit from the prewindowed sections of x andy e mean to remove the mean from the prewindowed sections of x and y e none for no detrending default The df lag parameter must appear last in the list of input arguments coher e recognizes a df ag string no matter how many intermediate arguments are omitted cohere with no output arguments plots the coherence estimate versus frequency in the current figure window cohere Example Compute and plot the coherence esti mate between two colored noise sequences x andy h firl 30 0 2 boxcar 31 hl ones 1 10 sqrt 10 r randn 16384 1 x filter hl 1 r y filter h 1 x cohere x y 1024 512 Coherence Function Estimate fay I gt N T e a T ind ES T Coherence Function Estimate o a T d w T n n fi fi fi fi I 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Frequency Diagnostics An appropriate diagnostic messages is displayed when incorrect arguments are used Requires window s length to be no greater than the FFT length Requires NOVERLAP to b
271. fectively removes the upper sideband modulate pm pwm ptm qam Frequency modulation Creates a sinusoid with instantaneous frequency that varies with the message signal x y cos 2 pi Fc t opt cumsum x cums um is a rectangular approximation to the integral of x modulate usesopt as the constant of frequency modulation If opt is not present modul ate uses a default of opt Fc Fs 2 pi max max x so the maximum frequency excursion fromFc isFc Hz Phase modulation Creates a sinusoid of frequency Fc whose phase varies with the message signal x y cos 2 pi Fc t opt x modulate usesopt as the constant of phase modulation If opt is not present modul at e uses a default of opt pi max max x so the maximum phase excursion is mx radians Pulse width modulation Creates a pulse width modulated signal from the pulse widths in x The elements of x must be between 0 and 1 specifying the width of each pulsein fractions of a period The pulses start at the beginning of each period that is they are left justified modulate x Fc Fs pwm centered yields pulses centered at the beginning of each period y is length length x Fs Fc Pulse time modulation Creates a pulse time modulated signal from the pulse times in x The elements of x must be between 0 and 1 specifying the left edge of each pulse in fractions of a period opt isa scalar between 0 and 1 that specifies the length of each pulse in
272. fferent components of the Filter Designer s interface and how you can use them together to create and edit filters Menus File Menu Use Close from the File menu to close the Filter Designer Settings you changed and saved using the Preferences window in SPTool are saved and used the next time you open the Filter Designer Window Menu Use the Window menu to select a MATLAB Figure window Using the Filter Designer Interactive Filter Design General controls Specifications panel for setting filter parameters Apply the specifications or revert to the previous specifications Viewing zoom controls Measurements panel for viewing filter characteristics oa QI Sa jus Filter magnitude response display area Filter Pop Up Menu The Filter pop up menu displays all of the filters currently selected in SPTool Select a filter in the menu to make it the current filter in the Filter Designer Zoom Controls The available zoom controls in the Filter Designer are Zoom In Y Zoom Out Y Zoom In X Zoom Out X Pass Band Full View and Mouse Zoom See Zoom Controls on page 5 30 for details on using the zoom controls Zoom persistence is off by default in the Filter Designer use the Filter Designer settings panel in the Preferences dialog to toggle zoom persistence on and off See Filter Designer Settings on page 5 28 Help Button To use context sensitive help click on the Help b
273. fication See the Algorithm section for more on npt andl ap The desired frequency response is interpolated onto a dense evenly spaced grid of length npt npt is 512 by default If two successive values of f arethe same a region of ap points is set up around this frequency to provide a smooth but steep transition in the requested frequency response By default ap is 25 The filter coefficients are obtained by applying an inverse fast F ourier transform to the grid and multiplying by a window by default this is a Hamming window fir2 Example See Also Design a 30th order lowpass filter and overplot the desired frequency response with the actual frequency response f b 0 0 6 0 6 1 fir2 30 f m m 11 0 0 h w fregz b 1 128 plot f m w pi abs h 1 2 Window based finite impulse response filter design 0 8 0 6 0 44 0 2 K 04 02 03 04 05 0 6 0 7 08 0 9 1 butter Butterworth analog and digital filter design chebyl Chebyshev type I filter design passband ripple cheby2 Chebyshev type II filter design stopband ripple ellip Elliptic Cauer filter design firl standard response maxflat Generalized digital Butterworth filter design remez Parks McClellan optimal FIR filter design yul ewal k Recursive digital filter design 6 143 fircls Purpose Syntax Description Constrained least square FIR filter design for multiband filters b fircls
274. fied periodograms of detrended sections of a signal Simply specify the parameters that control the algorithm as arguments to the function An estimate for the PSD of asequencexn usingps d s default FFT length 256 window Hanning of length 256 overlap samples none and detrending option remove best linear fit from sections is Pxx psd xn If the original sequencexn has units of volts Pxx has units of volts Hz Torecreate the last example accurately specify 128 as the number of samples to overlap and ask for no detrending nfft 256 length of FFT Fs 1000 sampling frequency window hanning 256 window function noverlap 128 number of samples overlap dflag none detrending option Pxx psd xn nfft Fs window noverl ap dflag The order of the inputs tops d is important except for thedf ag string which can bein any position as longas it is last The sampling frequency doesn t affect the PSD estimate but helps psd scale the frequency axis for plotting psd without any outputs generates a plot psd xn nfft Fs window noverl ap dfl ag o OO 26 T ho a Power Spectrum Magnitude dB o o L L 1 L 1 L L L L 50 100 150 200 250 300 350 400 450 500 Frequency Spectral Analysis If you want to plot the PSD yourself obtain a frequency vector through an additional output argument Pxx f psd xn nfft Fs 256 noverlap dflag plot f 10 lo0g10 Pxx
275. figuration and filter length Think of frequency bands as lines over short frequency intervals r emez and firls usethis scheme to represent any piecewise linear desired function with 2 23 2 Filter Design 2 24 any transition bands fi rls andremez design lowpass highpass bandpass and bandstop filters a bandpass example is f 0 3 4 7 8 1 band edges in pairs a 0 0 1 1 0 0 bandpass filter amplitude Technically thesef anda vectors define five bands e Two stopbands from 0 0 to 0 3 and from 0 8 to 1 0 e A passband from 0 4 to 0 7 e Twotransition bands from 0 3 to 0 4 and from 0 7 to 0 8 Example highpass and bandstop filters are f 0 7 8 1 band edges in pairs a 0 0 1 1 highpass filter amplitude f 0 3 4 5 8 1 band edges in pairs a 1 1 0 0 1 1 bandstop filter amplitude An example multiband bandpass filter is f 0 t 215 25 59 24 245 255 2657 278 85 9 1 a 1 1 0 0 1210 0 1 1 0 0 212 Another possibility is a filter that has as a transition region the line connecting the passband with the stopband this can help control runaway magnitude response in wide transition regions f 0 4 42 48 5 1 a l 1 8 2 0 0 passband linear transition stopband The Weight Vector Bothfirls andremez allow you to place more or less emphasis on minimizing the error in certain frequency bands relative to others To do this specify a weight vector following the frequ
276. filter than thefir1 andfir2 functions These functions design Hilbert transformers differentiators and other filters with odd symmetric coefficients type III and type IV linear phase They also let you include transition or don t care regions in which the error is not minimized and perform band dependent weighting of the minimization firls iS an extension of thefir1 andfir2 functions in that it minimizes the integral of the square of the error between the desired frequency response and the actual frequency response remez implements the Parks McClellan algorithm which uses the Remez exchangealgorithm and Chebyshev approximation theory to design filters with optimal fits between the desired and actual frequency responses Thefilters are optimal in the sense that they minimize the maximum error between the desired frequency response and the actual frequency response they are sometimes called minimax filters Filters designed in this way exhibit an equiripple behavior in their frequency response and hence are also known as equiripple filters The Parks McClellan FIR filter design algorithm is perhaps the most popular and widely used FIR filter design methodology The syntax for firls andremez is thesame the only difference is their minimization schemes The next example shows how filters designed with firls andremez reflect these different schemes Basic Configurations The default mode of operation of fi rls andremez istodesign typ
277. findstheminimumorder n and cutoff frequencies Wn for an analog filter In this case the frequenciesin Wp and Ws are in radians per second and may be greater than 1 Usecheb2ord for lowpass highpass bandpass and bandstop filters as described under Digital Domain For data sampled at 1000 Hz design a lowpass filter with less than 3 dB of attenuation from 0 to 100 Hz and attenuation at least 15 dB from 150 Hz to the Nyquist frequency Wo 100 500 Ws 150 500 Rp 3 Rs 15 n Wn cheb2ord Wp Ws Rp Rs n Wn 0 2609 b a cheby2 n Rs Wn freqz b a 512 1000 n 3 Chebyshev Type I Lowpass Filter T T nN is T T T Magnitude Response dB n f f f f n f f f 50 100 150 200 250 300 350 400 450 500 Frequency Hertz 0 T T T T T T T T 504 i wea te Phase degrees a oO T i f f f f i f 1 f 50 100 150 200 250 300 350 400 450 500 Freauencv Hertz cheb2ord Next design a bandpass filter with a passband of 100 Hz to 200 Hz less than 3 dB of attenuation throughout the passband and 30 dB stopbands 50 Hz out on both sides of the passband Wp 100 200 500 Ws 50 250 500 Rp 3 Rs 30 n Wn cheb2ord Wp Ws Rp Rs n Wn 0 1633 0 4665 b a cheby2 n Rs Wn freqz b a 512 1000 n 4 Chebyshev Type II Bandpass Filter 7 7 7 1 Magnitude Response dB L L 1 L ii L i L i 50 100 150 200 250 300 350 400
278. four component tools The new settings are saved on disk and are used when you restart MATLAB In the preferences panels you can e Select colors and markers for rulers and set the initial ruler style e Select color and line style sequence for displayed signals e Configure axis labels and enable disable rulers panner and mouse zoom in the Signal Browser e Configure axis parameters and enable disable rulers and mouse zoom in the Spectrum Viewer e Configure filter and axis parameters and enable disable mouse zoom in the Filter Viewer e Configure tiling preferences in the Filter Viewer e Specify FFT length and enable disable mouse zoom and grid in the Filter Designer e Configure plug ins When you first select Preferences the Preferences dialog box is set to Rulers You can change the settings for rulers or click on any of the other settings categories to customize other settings Click once on a settings category to select it The following sections describe all of the settings you can modify The illustrations show the default settings for each category For additional information on preference settings use the Help button at the bottom of the Preferences dialog box 5 21 5 Interactive Tools Ruler Settings The Rulers preferences apply to the rulers in the Signal Browser Spectrum Viewer and Filter Viewer Prokerencen for OP Teal zj SSeS Se Se ey p Ruler Color Specifies the color of the ruler
279. fractions of a period The default for opt is 0 1 y is length length x Fs Fc Quadrature amplitude modulation Creates a quadrature amplitude modulated signal from signals x andopt y x cos 2 pi Fc t opt sin 2 pi Fc t opt must be the same size asx 6 219 modulate See Also 6 220 If you do not specify met hod then mo dul ate assumes am Except for thepwm and ptm cases y is thesame size as x Ifx isan array modul ate modulates its columns y t modulate x Fc Fs returnstheinternal timevectort that modul ate uses in its computations demod Demodulation for communications simulation vco Voltage controlled oscillator pburg Purpose Syntax Description Example Power spectrum estimate using the Burg method Pxx pburg x p nfft Pxx freq pburg x p nfft Fs Pxx freg a pburg pburgf pburg estimates the power spectral density PSD of the signal vector x n using the Burg method This method fits an autoregressive AR model to the lattice reflection coefficients estimated from the signal Since it represents the spectrum by an all pole model the correct choice of the model order p is crucial pburg returns the same results as pyul ear for large signal lengths Pxx pburg x p nfft returnsPxx the power spectrum estimate x is the input signal p is the model order for the all pole filter and nf ft is the FFT length defaults to 256 if not specified Pxx freq
280. frequency modulation 6 219 frequency points freqz 1 24 1 26 range 1 26 spacing 1 26 Frequency Range pop up menu Spectrum Viewer 5 90 frequency response 1 24 arbitrary 2 13 6 141 example 1 25 in Filter Viewer 5 73 5 74 5 80 inverse 6 186 Kaiser window 4 6 linear phase 2 17 magnitude 1 26 minimized error between desired and actual 2 22 monotonic 2 9 multiband 2 13 of Bessel prototype 2 11 of Butterworth prototype 2 8 of Chebyshev type prototype 2 9 of Chebyshev type II prototype 2 10 of Chebyshev window 4 9 of elliptic prototype 2 10 phase 1 26 unwrapping 1 27 plotting 1 25 points at which evaluated 1 24 spacing 6 159 specifying sampling frequency 1 24 Frequency Scale pop up menu Spectrum Viewer 5 90 frequency transformation 2 38 example 2 40 lowpass to bandpass 6 202 lowpass to bandstop 6 205 lowpass to highpass 6 207 Index lowpass to lowpass 6 209 frequency vector 6 256 freqz 1 24 6 3 6 160 frequency points 1 24 sampling frequency 1 24 spacing 6 159 From Disk radio button in Import dialog box 5 9 From Workspace radio button in Import dialog box 5 9 fscanf 1 13 Full View button 5 31 G gauspuls 1 9 1 10 6 2 6 163 Gauss Newton method 6 188 6 192 generalized Butterworth filter 2 14 generalized cosine window 4 4 Gibbs effect 2 19 reduced by window 4 2 graphical user interface GUI xii 1 3 grid lines in Filter Designer 5 21 5 28 group delay 1 28 5 18 6 165 defined 1 28 example 1 29 of
281. frequency points where bw is the fraction of the total frequency band interval 0 1 covered byf Increasing grid often results in filters that are more exactly equiripple but which take longer to compute The default value of 16 is the minimum value that should be specified for grid Note that the grid argument must bea 1 by 1 cell array b remez n f fresp w returns row vector b containing then 1 coefficients of the order n FIR filter whose frequency amplitude characteristics best approximate the response specified by function f resp The function is called from within remez with the following syntax dh dw fresp n f gf w 6 257 remez 6 258 The arguments are similar to those for r e mez e n isthe filter order e f is the vector of frequency band edges that appear monotonically between 0 and 1 where 1 is the Nyquist frequency gf is a vector of grid points that have been linearly interpolated over each specified frequency band by r emez gf determines the frequency grid at which the response function must be evaluated and contains the same data returned by cremez in thef grid field of theopt structure w iS a vector of real positive weights one per band used during optimization w is optional in the call tor e mez if not specified it is set to unity weighting before being passed to fresp dh and dw are the desired complex frequency response and band weight vectors respectively evaluated
282. ft logh rcunwrap iS a Special version of unwrap that subtracts a straight line from the phase cceps See Also References icceps Inverse complex cepstrum hil bert Hilbert transform rceps Real cepstrum and minimum phase reconstruction unwrap Unwrap phase angles 1 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 2 EEE Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 6 39 cheblap Purpose Syntax Description See Also References 6 40 Chebyshev type analog lowpass filter prototype z p k cheblap n Rp z p k cheblap n Rp returns the zeros poles and gain of an order n Chebyshev type analog lowpass filter prototype with Rp dB of ripple in the passband It returns the poles in the length n column vector p and the gain in scalar k z isan empty matrix because there areno zeros Thetransfer function is X z s k p s s pO s p 2 s p n H s Chebyshev type I filters are equiripple in the passband and monotonic in the stopband The poles are evenly spaced about an ellipse in the left half plane The Chebyshev type cutoff frequency gt is set to 1 0 for a normalized result This is the frequency at which the passband ends and the filter has magnitude response of 10 RP 20 bessel ap Bessel analog lowpass filter prototype buttap Butterworth analog and dig
283. g nterfacereference manual for details MATLAB reads such files using the oad command Similar techniques are available for exporting data generated within MATLAB See Using MATLAB for more details on importing and exporting data and see the online MATLAB Function Reference for descriptions of file loading and I O routines 1 13 1 Signal Processing Basics Filter Implementation and Analysis This section describes how to filter discrete signals using MATLAB sfi t er function and other functions in the Signal Processing Toolbox It also discusses how to use the toolbox functions to analyze filter characteristics including impulse response magnitude and phase response group delay and zero pole locations Convolution and Filtering The mathematical foundation of filtering is convolution MATLAB s conv function performs standard one dimensional convolution convolving one vector with another conv 1 1 1 1 1 1 ans NOTE Convolve rectangular matrices for two dimensional signal processing using theconv2 function A digital filter s output y n is related to its input x n by convolution with its impulse response h n y n hin x n h n m x m m co If a digital filter s impulse response h n is finite length and the input x n is alsofinite length you can implement the filter usingc onv Store x n in a vector x h n in a vector h and convolve the two x randn 5 1 a random vec
284. g 6 52 analog prototype 2 9 2 38 6 40 bandpass configuration analog 6 53 digital 6 51 bandstop configuration analog 6 53 digital 6 52 characteristics 2 9 design 6 51 digital 6 51 highpass configuration analog 6 53 digital 6 52 lowpass configuration analog 6 52 digital 6 51 order estimation 2 7 6 41 oO oa o Chebyshev type II filter analog 6 57 analog prototype 2 38 6 45 bandpass configuration analog 6 58 digital 6 56 bandstop configuration analog 6 58 digital 6 57 characteristics 2 10 design 6 56 digital 6 56 highpass configuration analog 6 58 digital 6 57 limitations 6 55 lowpass configuration analog 6 57 digital 6 56 order estimation 2 7 6 46 Chebyshev window 4 9 6 50 frequency response 4 9 chirp 1 9 6 2 6 61 chirp signal chirp z transform CZT 4 33 6 89 compared to discrete F ourier transform 4 33 execution time 4 34 for narrowband frequency analysis 6 89 classical IIR filter design 2 8 click and drag panning in Signal Browser 5 46 coefficients correlation 6 74 filter 1 15 linear prediction 6 211 reflection 1 37 6 234 6 252 cohere 3 6 3 16 6 6 6 65 Index coherence 3 15 6 65 defined 3 15 coherence function 3 15 Color button 5 34 color order in Signal Browser 5 23 in Spectrum Viewer 5 23 Color Order text box 5 23 color customizing in SPTool 5 21 column index vector entering in Signal Browser 5 44 column array 5 44 communications 4 10 communications simulation 4 28 6 98
285. g Computation Parameters 2 005 5 93 Computation Methods and Parameters 055 5 94 Setting Confidence IntervalS 0 000 aaran 5 98 Saving Spectrum Data 0 002 cee eee 5 98 Example Generation of Bandlimited Noise 5 100 Create Import and Namea Signal 5 101 Design a Filter a cece ees 5 102 Apply the Filter toa Signal 00 02 e eeu 5 104 View and Play the Signals 0 0 0c cence 5 105 Compare Spectra of Both Signals 0 00a eee 5 107 Reference 6 x Contents Before You Begin What Is the Signal Processing Toolbox xii How to Use This Manual 00005 xiii Installation a XV Typographical Conventions 0 0000 xvi Technical Notations 0 eee eee eae xvii Before You Begin What Is the Signal Processing Toolbox xii This section describes how to begin using the Signal Processing Toolbox It explains how to use this manual and points you to additional books for toolbox installation information The Signal Processing Toolbox is a collection of tools built on the MATLAB numeric computing environment The toolbox supports a wide range of signal processing operations from waveform generation to filter design and implementation parametric modeling and spectral analysis The toolbox provides two categories of tools e Signal pro
286. g Frequency fromthe SPTool Edit menu see Editing Data Objects in SPTool on page 5 16 The frequency axis of the magnitude response plot is updated to reflect the new sampling frequency Overlay Spectrum The Filter Designer allows you to overlay a signal spectrum on the filter s magnitude response plot Press the Overlay Spectrum button todisplay alist of the current spectra in SPTool Select a spectrum from the list and press OK to overlay it on the current magnitude response plot Note that the spectrum is plotted on the existing frequency axis which is scaled to the filter s sampling frequency Using the Filter Designer Interactive Filter Design D Winrar Ode M Miria Dija Filter Specifications Panel When you design a new filter the Filter Designer initially contains the specifications and magnitude response plot for an order 22 lowpass equiripple filter as shown in the panel at the left Use the Type pop up menu in the Specifications panel to select a band configuration Use the edit boxes below it in the panel to change the band edge frequencies and the amount of ripple in the passband and attenuation in the stopband Check the Minimum Order box to let the Filter Designer automatically determine the lowest filter order that achieves the current specifications The design parameters that are available in the Specifications panel depend on the filter design selected in the Algorithm pop up menu the band c
287. g modified Yule Walker equations see Chapter 2 Because yu ewal k is geared explicitly toward ARMA filter design it is discussed in Chapter 2 pburg andpyul ear are discussed in Chapter 3 along with the other nonparametric spectral estimation methods Time Domain Based Modeling Thel pc prony andst mcb functions find the coefficients of a digital rational transfer function that approximates a given time domain impulse response pc is restricted to all pole models and st mcb can accept an input besides an impulse that causes the output response The algorithms differ in complexity and accuracy of the resulting model Linear Prediction AR Modeling Linear prediction models a given signal x as the impulse response of an all pole filter It assumes that each output sample of a signal x k isa linear combination of the past n outputs that is it can be linearly predicted from these outputs and that the coefficients are constant from sample to sample x k a 2 x k 1 a 3 x k 2 s a n I x k n An nth order all pole mode of a signal x is a pc x n pc uses the autocorrelation method of all pole modeling to find the linear prediction coefficients This technique is also called the YuleWalker AR method of spectral analysis The filter generated is stable but it might not model the process exactly even if the data sequence is truly an autoregressive AR process of the correct order
288. g to select a different scaling Frequency Axis Scaling Specifies the scaling units for the frequency x axis in the Spectrum Viewer Scaling units can be linear or log Click in the pop up menu and drag to select a different scaling Frequency Axis Range Specifies the numerical range for the frequency x axis in the Spectrum Viewer Scaling options are 0 F s 2 0 F s or Fs 2 Fs 2 Click in the pop up menu and drag to select a different frequency range Rulers Click in the check box to display checked or hide unchecked the ruler buttons and the ruler panel in the Spectrum Viewer See Ruler Controls on page 5 32 for details on using the rulers in the Spectrum Viewer Stay in Zoom mode After Zoom Click in the check box to enable checked or disable unchecked zoom persistence in the Spectrum Viewer See Zoom Controls on page 5 30 for details on zoom controls in the Spectrum Viewer 5 25 5 Interactive Tools Filter Viewer Settings The Filter Viewer preferences let you set key filter plot configuration parameters and toggle zoom persistence i Preeheronces for OPT ol FFT Length Specifies the number of points used for the magnitude phase and group delay plots Type in a new value to change the FFT length Time Response Length Specifies the time response length for theimpulse and step response plots An empty value indicates that a response length will automatically be determined usi
289. gauspuls generates Gaussian modulated sinusoidal pulses yi gauspuls t fc bw returns a unity amplitude Gaussian RF pulse at the times indicated in arrayt with a center frequency fc in Hertz anda fractional bandwidth bw which must be greater than 0 The default value for f c is 1000 Hz and for bw is 0 5 yi gauspuls t fc bw bwr returns a unity amplitude Gaussian RF pulse with a fractional bandwidth of bw as measured at a level of bwr dB with respect to the normalized signal peak The fractional bandwidth reference level b wr must be less than 0 because it indicates a reference level less than the peak unity envelope amplitude The default value for bwr is 6 dB yi yq gauspuls returns both the in phase and quadrature pulses yi yg ye gauspuls returns theRF signal envelope tc gauspuls cutoff fc bw bwr tpe returns the cutoff timet c greater than or equal to 0 at which the trailing pulse envelope falls below t pe dB with respect to the peak envelope amplitude The trailing pulse envelope level t pe must beless than 0 because it indicates a reference level less than the peak unity envelope amplitude The default value for t pe is 60 cB Default values are substituted for empty or omitted trailing input arguments 6 163 gauspuls Example Plot a 50 KHz Gaussian RF pulse with 60 bandwidth sampled at a rate of 1 MHz Truncate the pulse where the envelope falls 40 dB below the peak tc
290. ge of the confidence interval Pxx Pxxc f psd x nfft Fs window noverlap p dflag Pxy Pxyc f csd x y nfft Fs window noverl ap p dflag p must bea scalar between 0 and 1 The functions assume chi squared distributed periodograms of nonoverlapping sections in computing the confidence intervals This assumption is valid when the signal is a Gaussian distributed random process Provided these assumptions are correct thereis a p 100 probability that the confidence interval Pxx Pxxc 1 Pxx tPxxc 2 covers the true PSD If the sections overlap the confidence interval is not reliable and the functions display a warning message Transfer Function Estimate One application of Welch s method is nonparametric system identification Assume that H is a linear time invariant system and x n and y n are the input to and output of H respectively Then the PSD of x n is related to the CSD of x n and y n as Pyy H Pyy An estimate of the transfer function between x n and y n is g H Fy Py This method estimates both magnitude and phase information Thet f e function uses Welch s method to compute the CSD and PSD and then forms their quotient for the transfer function estimate Uset f e the same way that you use thecsd function Spectral Analysis Filter thesignal xn with an FIR filter then plot the actual magnitude response and the estimated response h ones 1 10 10 moving averag
291. gn filter Filter data with a recursive IIR or nonrecursive FIR filter freqz Frequency response of digital filters 1 Selesnick W and C S Burrus Generalized Digital Butterworth Filter Design Proceedings of thel EEE Int Conf Acoust Speech Signal Processing Vol 3 May 1996 medfilt1 Purpose Syntax Description See Also References One dimensional median filtering y medfiltl x n y medfiltl x n bl ksz y medfilti x n applies an order n one dimensional median filter to vector x y is the same length as x the function treats the signal as if it is O beyond the end points Forn odd y k isthe median of x k n 1 2 k n 1 2 Forn even y k isthe median of x k n 2 x k n 2 41 x k n 2 1 In this case me df i t 1 sorts the numbers then takes the average of the n 1 2 and n 1 2 1 elements The default for n is 3 y medfiltl x n bl ksz usesafor loop to compute b ksz block size output samples at atime Usebl ksz lt lt length x if you are low on memory since medfi t1 uses a working matrix of sizen by b ksz By default blksz length x thisis the fastest execution if you have sufficient memory If x isa matrix medfi t1 median filters its columns using y i medfiltl x i n bl ksz in a loop over the columns of x filter Filter data with a recursive IIR or nonrecursive FIR filter medfilt2 Two dimensional median filtering see mage
292. gn 2 4 2 5 analog prototype 2 5 Butterworth 2 7 2 8 5 66 5 67 Chebyshev 2 7 2 9 2 10 5 66 5 67 classical analog prototype 2 5 2 8 comparison of filter types 2 8 general steps 2 37 illustration 2 37 in Filter Designer 5 66 order estimation 2 7 plotting prototypes 2 12 single step 2 6 single step order estimation 2 7 system model 2 7 direct methods 2 13 Yule Walker 2 13 elliptic 2 7 2 10 5 66 5 67 example 5 66 5 68 generalized Butterworth 2 14 in Filter Designer 5 55 5 66 maximally flat 2 14 parameters in Filter Designer 5 67 to specifications 2 7 Se also direct design parametric modeling IIR lattice filter implementation 1 38 image processing 6 70 withfft2 andifft2 1 45 impinvar 2 5 2 41 6 10 6 177 Import As pop up menu in Import dialog box 5 10 Import menu item 5 5 5 7 imported filter in SPTool 5 15 impulse invariance 2 41 6 177 limitations 2 41 impulse response 1 23 5 18 6 179 and impulse invariance 2 41 computing with f i Iter 1 23 computing with i mpz 1 23 defined 1 23 example 1 23 of ideal lowpass filter 2 19 viewing in Filter Viewer 5 85 Impulse Response check box Filter Viewer 5 77 impulse response plot 5 77 5 85 impz 6 3 6 179 example 1 23 indexing of vectors 1 15 Inherit from pop up menu Spectrum Viewer 5 91 inheriting parameters 5 91 initial conditions 1 17 1 21 6 135 generating 1 18 Initial Type pop up menu in Preferences dialog box 5 22 instantaneous attributes 4 38 6 170 int
293. gnal that is shown in the main axes is shown in the panner with a window around it 5 51 5 Interactive Tools 5 52 Each time you zoom the panner is updated to frame the region of data displayed in the main axes Click and drag on the panner window to moveit As the window moves over the signal in the panner the signal in the main axes area is panned Manipulating Displays Changing Signal Displays The signals are displayed in the default line colors and default line styles You can change the defaults using the Color Order and Line Style Order fields in the Colors settings panel see Color Settings on page 5 23 Changing the Sample Interval You can change the sample interval by selecting Sampling Frequency from the Edit menu in SPTool See Editing Data Objects in SPTool on page 5 16 Displaying Complex Signals You can change how complex numbers are displayed by selecting Real Imaginary Magnitude or Angle from the pop up menu See Array Signals Button on page 5 44 Changing Signal Browser Displays Using the Signal Browser settings panel in Preferences you can set optional x axis and y axis labels enable and disable the display of the rulers and the panner and toggle zoom persistence See Signal Browser Settings on page 5 24 Using the Signal Browser Interactive Signal Analysis Working with Signals Once a signal is displayed you can browse it in a variety of ways e You c
294. gorithm See Also Plot both the group and phase delays of a system on the same graph gd grpdelay b a 512 gd 1 h w pd 1 avoid NaNs freqz b a 512 h 1 wl unwrap angle h w plot w gd w pd 45 40 357 30 7 257 207 Group Delay 4 Phase Delay 0 5 1 1 5 2 2 5 3 3 5 Frequency rad sec grpdel ay multiplies the filter coefficients by a unit ramp After F ourier transformation this process corresponds to differentiation cceps fft freqz hilbert icceps rceps Complex cepstral analysis One dimensional fast Fourier transform Frequency response of digital filters Hilbert transform Inverse complex cepstrum Real cepstrum and minimum phase reconstruction 6 167 hamming Purpose Syntax Description Diagnostics See Also References 6 168 Hamming window w hammi ng n w hamming n sflag w hamming n returnsann point symmetrically sampled Hamming window in the column vector w n should be a nonnegative integer The coefficients of a Hamming window are n Wik 1 0 5406 cos 27 i k 0 n 1 w hamming n sflag returns ann point Hamming window using the window sampling specified by sf ag which can be either periodic or symmetric the default When peri odic is specified hammi ng computes a length n 1 window and returns the first n points An error message is displayed wh
295. h w freqs b a h w freqs b a n freqs b a f reqs returns the complex frequency response H jw Laplace transform of an analog filter _ B s _ DAs b 2 s b nb 1 H s i ACS a 1 s a aD a na 1 given the numerator and denominator coefficients in vectors b anda h freqs b a w returns the complex frequency response of the analog filter specified by coefficient vectorsb anda f reqs evaluates the frequency response along the imaginary axis in the complex plane at the frequencies specified in real vector w h w freqs b a automatically picks a set of 200 frequency points w on which to compute the frequency response h h w freqs b a n picksn frequencies on which tocomputethefrequency response h freqs with no output arguments plots the magnitude and phase response versus frequency in the current figure window f reqs works only for real input systems and positive frequencies freqs Example Find and graph the frequency response of the transfer function given by _ 0 257 0 3s 1 H s 5 s 0 45 1 a 1 0 4 1 Deer 20 2 02 31 w logspace 1 1 freqs b a w 10 gp PEE EEE S 10 E g S 10 10 10 10 Frequency 0 T 8 50H koJ o 100F J Ean a 150 10 10 10 Frequency You can also create the plot with h freqgs b a w mag abs h phase angle h subplot 2 1 1 loglog w mag subplot 2 1 2
296. hat is the entire data sequence is available prior to filtering This allows for a noncausal zero phase filtering approach via thefi tfilt function which eliminates the nonlinear phase distortion of an IIR filter The classical IIR filters Butterworth Chebyshev types and II elliptic and Bessel all approximate the ideal brickwall filter in different ways This toolbox provides functions to create all thesetypes of classical IIR filters in both the analog and digital domains except Bessel for which only the analog case is supported and in lowpass highpass bandpass and bandstop configurations F or most filter types you can also find the lowest filter order that fits a given filter specification in terms of passband and stopband attenuation and transition width s The direct filter design function yul ewal k finds a filter with magnitude response approximating a desired function This is one way to createa multiband bandpass filter You can also usethe parametric modeling or system identification functions to design IIR filters These functions are discussed in the Parametric Modeling section of Chapter 4 The generalized Butterworth design function maxf at is discussed in the section Generalized Butterworth Filter Design on page 2 14 The following table summarizes the various filter methods in the toolbox and lists the functions available to implement these methods IIR Filter Design Method
297. hat the second plot reflects a slightly lower noise floor which is the result of a longer window length Spectral Analysis Parseval s Relation According to Parseval s relation the integral of the PSD across the entire band is a measure of the total energy of the signal The results of psd can approximately verify this Pxx f psd xn 256 Fs 256 128 none format long sum xn 2 length xn ans 3 60376766505040 sum Pxx length Pxx ans 3 68430077838701 To approximate the percentage of energy the signal has in a given frequency band sum the PSD estimate at the desired frequency points only The percentage of energy of xn in the band from 40 to 60 Hz is ind find f gt 40 amp f lt 60 ind 12 13 14 15 16 sum Pxx ind sum Pxx ans 0 13369450463404 Cross Spectral Density Function Toestimatethe cross spectral density of two equal length signalsx andy using Welch s method thecsd function forms the periodogram as the product of the FFT of x and the conjugate of the FFT of y Unlike the real valued PSD the 3 13 3 Statistical Signal Processing 3 14 CSD is a complex function csd handles the sectioning detrending and windowing of x and y in the same way as the ps d function Pxy csd x y nfft Fs window noverl ap dflag Confidence Intervals Both thepsd andcsd functions can compute confidence intervals Simply provide an input argument p which specifies the percenta
298. he Label field e Click the Line Style pop up menu and drag to select a line style as shown on the left e Click a radio button to select a color If you select Other you can type a color value in the Enter colorspec box the color value can bea string e g r or an RGB triple eg 1 0 0 e Click OK to apply the line style and color you selected Find Ruler Buttons Use the find ruler buttons to bring one or both rulers into the viewing area of the main axes When both rulers are within the signal display main axes area the find ruler buttons at the top right of the main axes area are not displayed If the rulers are not within the signal display area both Find Ruler buttons are displayed as shown on the right 112 If one ruler is within the signal display area the button for the other ruler is displayed as shown on the right 2 Click a Find Ruler button to bring the specified ruler into the display area When a ruler is visible you can click on it and drag it to make a measurement on the selected signal See Making Signal Measurements on page 5 37 for details on manipulating the rulers and measuring the selected signal Using SPTool Ruler Control Buttons Use the ruler control buttons to select the type of measurement you want to make Vertical Horizontal Track or Slope The default setting is Track Click a ruler control button to select it The Rulers panel changes depending on which ruler cont
299. he PSD of xn is Pxx abs fft xn 1024 2 1001 This estimate is called the periodogram Scale the magnitude squared of the FFT by the square of the norm of the data window applied to the signal in this Spectral Analysis case a length 1001 rectangular window to ensure that the estimate is asymptotically unbiased That is as the number of samples increases the expected value of the periodogram approaches the true PSD The problem with the periodogram estimate is that its variance is large on the order of the PSD squared and does not decrease as the number of samples increases The following two examples show this as FFT length increases the periodogram does not become smocther Pxx_ short plot 0 255 256 Fs 10 1 0g10 Pxx_short plot 0 1023 1024 Fs 10 10g10 Pxx 204 30 0 Power Spectrum dB Power Spectrum dB w Y So i 20 0 30 abs fft xn 256 2 256 Short Periodogram L 100 1 ji 1 1 1 1 ji 200 300 400 500 600 700 800 900 Frequency Hz Periodogram 1000 20 i 100 ii 1 1 1 1 1 1 200 300 400 500 600 700 800 900 Frequency Hz 1000 3 7 3 Statistical Signal Processing Reduce the variance of the PSD estimate by breaking the signal into nonoverlapping sections and averaging the periodograms of these sections Pxx abs fft xn 1 256 2 abs fft xn 257 512 2 abs fft xn 513 768 2 256 3 plot
300. he appropriate Signals list Filters list or Spectra list e Signals are displayed with the signal type vector or array A vector signal vector has one column of data An array signal array has more than one column of data e Filters are displayed with the filter type design or imported A designed filter desi gn is a filter that was created using the Filter Designer This type of filter can also be edited in the Filter Designer An imported filter i mport ed is a filter that was imported from the MATLAB workspace or a file It can be applied to a signal in SPTool but it cannot be edited in the Filter Designer e Spectra are displayed with the spectrum type auto An auto spectrum auto is a spectrum whose source is a single signal as opposed tothe cross spectrum of two channels of data s pect rum auto isthe only spectrum type in SPTool Selecting Data Objects in SPTool Each signal filter and spectrum in SPTool is one data object A data object is selected when it is highlighted When you first import or create a data object it is selected The Signals list shows all vector and array signals in the current SPTool session The Filters list shows all designed and imported filters in the current SPTool session The Spectra list shows all spectra in the current SPTool session 5 15 5 Interactive Tools 5 16 You can select a single data object in a list a range of data objec
301. he color of the line in the Selection display changes to correspond to the color of the spectrum that you ve selected The spectrum that s displayed in the Selection pop up menu and in the Selection display is the active spectrum When you usetherulers or change parameters the active spectrum is the one that is measured or modified 5 110 Reference 6 Reference 6 2 This chapter contains detailed descriptions of all Signal Processing Toolbox functions It begins with a list of functions grouped by subject area and continues with the reference entries in alphabetical order For more information see the online MATLAB Function Reference Waveform Generation and Plotting chirp Swept frequency cosine generator diric Dirichlet or periodic sinc function gauspuls Gaussian modulated sinusoidal pulse generator pulstran Pulse train generator rectpuls Sampled aperiodic rectangle generator Sawtooth Sawtooth or triangle wave generator sinc Sinc function square Square wave generator strips Strip plot tripuls Sampled aperiodic triangle generator Filter Analysis and Implementation abs Absolute value magnitude angle Phase angle conv Convolution and polynomial multiplication conv2 Two dimensional convolution fftfilt FF T based FIR filtering using the overlap add method filter Filter data with a recursive IIR or nonrecursive FIR filter Filter Analysis and Implementation f
302. he state vector and y is the output Analog Domain b a cheby2 n Rs Wn s designs an ordern lowpass analog Chebyshev type Il filter with cutoff frequency Wn It returns the filter coefficients in the lengthn 1 row vectorsb anda with coefficients in descending powers of s _ Bis _ B s 2 s b n 1 H s A s s 4a 2 s 4a n4 1 Cutoff frequency is the frequency at which the magnitude response of the filter is equal to Rs dB Forcheby2 the cutoff frequency Wn must be greater than 0 6 57 cheby2 Examples 6 58 If Wn is atwo element vector Wn wl w2 withwl lt w2 then cheby2 n Rs Wn s returns an order 2 n bandpass analog filter with passband w1 lt lt w2 b a cheby2 n Rs Wn ftype s designs a highpass or bandstop filter wheref type is e high for a highpass analog filter with cutoff frequency Wn e stop for an order 2 n bandstop analog filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 With different numbers of output arguments cheby2 directly obtains other realizations of the analog filter To obtain zero pole gain form usethree output arguments z p k cheby2 n Rs Wn s or z p k cheby2 n Rs Wn ftype s returns the zeros and poles in length n or 2 n column vectorsz andp and the gain in the scalar k To obtain state space form use four output arguments A B C D cheby2 n Rs Wn s or A B C D cheby2 n
303. here are no zeros The transfer function is z s p k p s s pU s p 2 s p n Butterworth filters are characterized by a magnitude response that is maximally flat in the passband and monotonic overall In the lowpass case the first 2n 1 derivatives of the squared magnitude response are zero at 0 The squared magnitude response funcion is H s 1 2 H ar iaw 1 0 00 corresponding to a transfer function with poles equally spaced around a cirde in the left half plane The magnitude response at the cutoff frequency wo is always 1 sqrt 2 regardless of the filter order but tap sets a to 1 for a normalized result LT exp sgqrt 1 pi 1 2 2 n 1 2 n pi 2 real prod p Z p k besselap Bessel analog lowpass filter prototype butter Butterworth analog and digital filter design cheblap Chebyshev type analog lowpass filter prototype cheb2ap Chebyshev type II analog lowpass filter prototype ellipap Elliptic analog lowpass filter prototype 1 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 Chapter 7 butter Purpose Syntax Description Butterworth analog and digital filter design b a butter n Wn b a butter n Wn ftype b a butter n Wn s b a butter n Wn ftype s z p k butter A B C D butter but ter designs lowpass bandpass highpass and bandstop digital and analog Butterwo
304. hich you must design using another function such asremez orfirt NOTE Thefunctionresamp e performs an FIR design usingf ir 1 followed by rate changing implemented with upfirdn yout upfirdn xin h returns the output signal yout Ifyout is a row or column vector then it represents one signal if yout is an array then each column is a separate output xi n is the input signal If xi n is a row or column vector then it represents one signal if xin is an array then each column is filtered h is the impulse response of the FIR filter Ifh is a row or column vector then it represents one filter if h isan array then each column isa separate impulse response yout upfirdn xin h p specifies the upsampling factor p p is an integer with a default of 1 yout upfirdn xin h p q Specifies the downsampling factor q q is an integer with a default of 1 upfirdn Remarks Examples NOTE Sinceupfirdn performs convolution and rate changing they out signals have a different length than xi n The length of y n is approximately p q times the length of x n Usually the inputs xin and the filter h are vectors in which case only one output signal is produced However when these arguments are arrays each column is treated as a separate signal or filter Valid combinations are 1 xin iS avector andh is a vector Thereis one filter and one signal so the function convolves xi n withh The output signal yout is a row vector if
305. highpass bandpass and bandstop configurations sptool e The Filter Viewer for viewing the characteristics of a designed or imported filter including its magnitude response phase response group delay pole zero plot impulse response and step response 6 291 sptool e The Spectrum Viewer for graphical analysis of frequency domain data using a variety of methods of spectral density estimation including the Burg method the FFT method the multitaper method MTM the MUSIC eigenvector method Welch s method PSD and CSD and the Yule Walker AR method Selection spect See Chapter 5 Interactive Tools for a full discussion of how to use SPTool 6 292 square Purpose Syntax Description See Also Square wave generator x square t x square t duty square t generates a square wave with period 27 for the elements of time vectort square t issimilar tosin t but it creates a square wave with peaks of 1 instead of a sine wave square t duty generates a square wave with specified duty cycle duty The duty cycleis the percent of the period in which the signal is positive chirp cos diric gauspuls pulstran rectpuls sawtooth sin sinc tripuls Swept frequency cosine generator Cosine of vector matrix elements see the online MATLAB Function Reference Dirichlet or periodic sinc function Gaussian modulated sinusoidal pulse generator Pulse train genera
306. his case f ft pads the input sequence with zeros if it is shorter than n or truncates the sequence if it is longer thann Ifn is not specified it defaults to the length of the input sequence Discrete Fourier Transform Execution time for f f t depends on the length n of the DFT it performs e For anyn that is a power of two f ft uses the high speed radi x 2 algorithm This results in the fastest execution time Additionally the algorithm for power of twon is highly optimized for real x providing a 40 speed up over the complex case For any composite number n that is not a power of two f ft uses a prime factor algorithm The speed of this algorithm depends on both the size of n and number of prime factors it has Although 1013 and 1000 are close in magnitude f f t transforms a sequence of length 1000 much more quickly than a sequence of length 1013 For a prime number n fft cannot use an FFT algorithm and instead performs the slower computation intensive DFT directly The inverse discrete Fourier transform function i f f t also accepts an input sequence and optionally the number of desired points for the transform Try the example below the original sequencex and the reconstructed sequence are identical within rounding error t Oe T2551 x sin 2 pi 120 t y real ifft fft x This toolbox also includes functions for the two dimensional FFT and its inverse f ft 2 andi f f t 2 Thesefunctions are useful for two
307. hoose the signal filter or spectrum you want to copy When you select a data object to duplicate it a new data object of the same type is automatically created The new data object is named as a copy of the selected data object It is placed at the bottom of the list and is selected You can change its name using Name from the Edit menu Using SPTool Clear Use Clear from the Edit menu to delete the selected signal filter or spectrum from SPT ool Click Clear and drag to choose the signal filter or spectrum you want to remove The data object is deleted from the current SPTool session Name Use Name from the Edit menu to give the selected signal filter or spectrum a new unique name 1 Click Name and drag to choose the signal filter or spectrum you want to rename The Name Change dialog box is displayed 2 Typein the new name and click OK Sampling Frequency Use Sampling Frequency from the Edit menu to supply a sampling frequency for a selected signal or filter The sampling frequency may be a number such as 1 0 001 1 5000 or a valid MATLAB expression including workspace variables such aSFs 1 Ts orcos 1 pi 1 Click Sampling Frequency and drag to choose the signal or filter you want to change The Sampling Frequency dialog box is displayed 2 Typein the value variable name or expression and click OK Viewing a Signal Use the Signal View button to makethe Signal Browser active and vie
308. iangular window for n even the slopes of the line segments of t ri ang s result are slightly steeper than those of bartlett sin this case w bartlett 8 w 2 7 triang 6 ans 2857 5714 8571 8571 5714 2857 o CoO OO a 1667 5000 8333 8333 5000 1667 The final difference between the Bartlett and triangular windows is evident in the Fourier transforms of these functions The Fourier transform of a Bartlett 4 3 4 Special Topics 4 4 window is negative for n even The Fourier transform of a triangular window however is always nonnegative This difference can be important when choosing a window for some spectral estimation techniques such as the Blackman Tukey method Blackman Tukey forms the spectral estimate by calculating the F ourier transform of the autocorrelation sequence The resulting estimate might be negative at some frequencies if the window s Fourier transform is negative see Kay 1 pg 80 Generalized Cosine Windows Blackman Hamming Hanning and rectangular windows are all special cases of the generalized cosine window These windows are combinations of sinusoidal sequences with frequencies 0 27 N 1 and 4x N 1 whereN is the window length One way to generate them is ind 0 n 1 2 pi n 1 w A B cos ind C cos 2 ind whereA B andC are constants you define The concept behind these windows is that by summing the individual terms to
309. iation from 0 stopband ripple of 0 008 f a 0 0 ds 0 008 1 Une 0 fis FIR Filter Design To approach this design problem usingfircls1 n 61 wo 0 3 dp 0 02 ds 0 008 h firclsl n wo dp ds plot 0 8 0 6 0 4 0 2 0 2 fi fi fi fi fi L fi f fi 0 0 41 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Multiband CLS Filter Design fircls uses the same technique to design FIR filters with a desired piecewise constant magnitude response In this case you can specify a vector of band edges and a corresponding vector of band amplitudes In addition you can specify the maximum amount of ripple for each band For example assume the specifications for a filter call for e From 0 to 0 3 normalized amplitude 0 upper bound 0 005 lower bound 0 005 e From 0 3 to 0 5 amplitude 0 5 upper bound 0 51 lower bound 0 49 e From 0 5 to 0 7 amplitude 0 upper bound 0 03 lower bound 0 03 e From 0 7 to 0 9 amplitude 1 upper bound 1 02 lower bound 0 98 e From 0 9 to 1 amplitude 0 upper bound 0 05 lower bound 0 05 2 29 2 Filter Design Design a CLS filter with impulse response order 129 that meets these specifications n 129 f 0 0 3 0 5 0 7 0 9 1 a 00 5 01 0 up 0 005 0 51 0 03 1 02 0 05 lo 0 005 0 49 0 03 0 98 0 05 h fircls n f a up lo plot 1 2 1H aa 0 8 F 0 6F 0 4F 0 2 L 1 fi 1 1 1 1 1 1 0 1
310. icient v k tf2latc num findsthelatticeparametersk for an FIR MA latticefilter normalized by num 1 The function atc2tf istheinverseoftf2latc latc2tf Lattice filter to transfer function conversion latcfilt Lattice and lattice ladder filter implementation poly2rc Reflection coefficients from polynomial coefficients rc2poly Polynomial coefficients from reflection coefficients tf2ss Purpose Syntax Description Example Transfer function to state space conversion A B C D tf2ss num den tf2ss converts a transfer function representation of a given system to an equivalent state space representation A B C D tf2ss num den finds a state space representation x Ax Bu y Cx Du given a system in transfer function form num s den s from a single input Input vector den contains the denominator coefficients in descending powers of s Array num contains the numerator coefficients with as many rows as there are outputs y tf 2ss returns theA 8 C andD matrices in controller canonical form H s C sI A B D tf2ss also works for discrete systems but you must pad the numerator with trailing zeros to make it the same length as the denominator The function ss2tf istheinverse oft f2ss Consider the system 254 3 s7 42541 H s esa s 0 4s 1 6 307 tf2ss Toconvert this system to state space num 0 2 3 1 2 1 den 1 0 1 A B C D tf2ss num den Ae
311. icking on x in the Workspace Contents list and then clicking on the arrow tothe left of the Data field c Click in the Sampling Frequency field and type5000 d Namethesignal by clicking in the Name field and typing noise e Click OK The SPTool window is reactivated andthesignal noi sef vector isselected in the Signals list Design a Filter You can import an existing filter into SPTool or you can design and edit a new filter using the Filter Designer In this step you ll create a default filter and customize it in the Filter Designer 1 Click New Design in SPTool to activate the Filter Designer and generate a default filter The Filter Designer window is displayed with the default filter fil t1 2 Change the filter sampling frequency to 5000 by entering this valuein the Sampling Frequency text box in the Filter Designer 3 Specify the filter parameters shown at left a Makesure Equiripple FIR is selected in the Algorithm pop up menu b Select bandpass from the Type pop up menu c Set the passband edge frequencies by entering 750 for Fpland1250 for Fp2 d Set the stopband edge frequencies by entering 500 for Fsland1500 for Fs2 e Type 01 intotheRp field and75 intotheRs field Rp sets the maximum passband ripple and Rs sets the stopband attenuation for the filter f Press the Apply button to compute the new filter Example Generation of Bandlimited N oise When the new filter is computed the magnitude response
312. idue State space ss2tf ss2zp 250S Zero pole zp2tf zp2ss zp2sos gain poly Partial resi duez fraction residue Lattice filter atc2tf Second sos2tf sos2ss sos2zp order sections Convolution matrix Many of the toolbox filter design functions use these functions internally F or example thezp2ss function converts the poles and zeros of an analog prototype into the state space form required for creation of a Butterworth Chebyshev or elliptic filter Oncein state space form the filter design function performs any required frequency transformation that is it transforms the initial lowpass design into a bandpass highpass or bandstop filter or a lowpass filter with the desired cutoff frequency See Chapter 6 and the reference descriptions of the individual filter design functions for more details Discrete Fourier Transform Discrete Fourier Transform The discrete Fourier transform or DFT is the primary tool of digital signal processing The foundation of the Signal Processing Toolbox is the F ast Fourier Transform FFT a method for computing the DFT with reduced execution time Many of the toolbox functions including z domain frequency response spectrum and cepstrum analysis and some filter design and implementation functions incorporate the FFT MATLAB provides the functions f ft andi f ft to compute the discrete F ourier transform and its inverse respectively For the input sequence x and its transformed version X
313. ifth order Butterworth lowpass filter usingfiltfilt y cos 2 pi Fc t a butter 5 Fc 2 Fs filtfilt b a x If you specify opt demod subtracts scalar opt fromx The default value for opt is O x b X ams s b Amplitude demodulation single sideband Multiplies y by a sinusoid of frequency Fc and applies a fifth order Butterworth lowpass filter usingfiltfilt x y cos 2 pi Fc t b a butter 5 Fc 2 Fs x filtfilt b a x demod pm ptm pwm qam Frequency demodulation Demodulates the FM waveform by modulating the Hilbert transform of y by a complex exponential of frequency Fc Hz and obtains the instantaneous frequency of the result Phase demodulation Demodulates the PM waveform by modulating the Hilbert transform of y by a complex exponential of frequency Fc Hz and obtains the instantaneous phase of the result Pulse time demodulation Finds the pulse times of a pulse time modulated signal y For correct demodulation the pulses cannot overlap x islength ength t Fc Fs Pulse width demodulation Finds the pulse widths of a pulse width modulated signal y de mod returnsinx a vector whose elements specify the width of each pulse in fractions of a period The pulses in y should start at the beginning of each carrier period that is they should be left justified Quadrature amplitude demodulation x1 x2 demod y Fc Fs gam multiplies y by a cosine and a sine of frequency Fc and
314. ilter in matrices At Bt Ct Dt 6 209 Ip2Ip Algorithm See Also 6 210 p2lp freque is a highly accurate state space formulation of the classic analog filter ncy transformation If a lowpass filter is to have cutoff frequency wy the standard s domain transformation is S Pp Oo The state space version of this transformation is At Bt Ct Dt See p bilin i mpi n p2bp p2bs p2hp Wo A Wo B zng D 2bp for a derivation of the bandpass version of this transformation ear Map variables using bilinear transformation var Impulse invariance method of analog to digital filter conversion Lowpass to bandpass analog filter transformation Lowpass to bandstop analog filter transformation Lowpass to highpass analog filter transformation Ipc Purpose Syntax Description Example Linear prediction coefficients a g pce x n Linear prediction models each sample of a signal as a linear combination of previous samples that is as the output of an all pole IIR filter It has applications in filter design speech coding spectral analysis and system identification a g pc x n finds the coefficients and gain of an nth order auto regressive linear process that models the time series x as x k a 2 x k 1 a 3 x k 2 a n 1 x kK n x isthe real input time series a vector and n is the order of the denominator polynomial a z thatis a 1 a 2
315. ilter design process for the butter chebyl cheby2 andel lip functions p2bs can perform the transformation on two different linear system representations transfer function form and state space form In both cases the input system must be an analog filter prototype Transfer Function Form Polynomial bt at p2bs b a Wo Bw transforms an analog lowpass filter prototype given by polynomial coefficients into a bandstop filter with center frequency Wo and bandwidth Bw Row vectorsb anda specify the coefficients of the numerator and denominator of the prototype in descending powers of s b s _ BOs b an s b n 1 a s a l s a nd s a nd 1 Scalars Wo and Bw specify the center frequency and bandwidth in units of radians second For a filter with lower band edgew1 and upper band edge w2 useWo sqrt wl w2 andBw w2 wl p2bs returns the frequency transformed filter in row vectors bt and at State Space Form At Bt Ct Dt p2bs A B C D Wo Bw converts the continuous time state space lowpass filter prototype in matricesA B C D x Ax Bu y Cx Du 6 205 Ip2bs Algorithm See Also 6 206 into a bandstop filter with center frequency Wo and bandwidth Bw For a filter with lower band edgewl and upper band edgew2 useWo sqrt wl w2 and Bw w2 wl The bandstop filter is returned in matrices At Bt Ct Dt p2bs isahighly accurate state space formulation of the classic analog fil
316. ilter2 filtfilt filtic freqs freqspace freqz grpdel ay i mpz latcfilt unwrap zplane Two dimensional digital filtering Zero phase digital filtering Find initial conditions for a transposed direct form II filter implementation Frequency response of analog filters Frequency spacing for frequency response Frequency response of digital filters Average filter delay group delay Impulse response of digital filters Lattice and lattice ladder filter implementation Unwrap phase angles Zero pole plot Linear System Transformations convmt x latc2tf poly2rc rc2poly resi duez SOS2SS sos2tf 0S2zp Convolution matrix Lattice filter to transfer function conversion Reflection coefficients from polynomial coefficients Polynomial coefficients from reflection coefficients z transform partial fraction expansion Second order section to state space conversion Second order section to transfer function conversion Second order section to zero pole gain conversion 6 3 6 Reference Linear System Transformations 52S0S ss2tf ss2zp tf2latc tf2ss tf2zp zp2sos zp2ss zp2tf State space to second order section conversion State space to transfer function conversion State space to zero pole gain conversion Transfer function to lattice filter conversion Transfer function to state space conversion Transfer function to zero pole gain conversion Zero pole gain to second orde
317. imag x real x abs Absolute value magnitude bartiett Purpose Syntax Description See Also Bartlett window w bartlett n w bartlett n returns ann point Bartlett window in the column vector w The coefficients of a Bartlett window are Forn odd 2 k 1 iepent n l1 2 w k 2k eal we n 1 2 Forn even BoD ait n l1 2 w k PME A epin n l1 2 The Bartlett window is very similar to a triangular window as returned by the triang function The Bartlett window always ends with zeros at samples 1 and n however while the triangular window is nonzero at those points For n odd the center n 2 points of bartl ett n are equivalent totriang n 2 blackman Blackman window boxcar Rectangular window chebwin Chebyshev window hammi ng Hamming window hanni ng Hanning window kaiser Kaiser window triang Triangular window 6 13 bartiett References 1 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 6 14 besselap Purpose Syntax Description Algorithm See Also References Bessel analog lowpass filter prototype z p k besselap n z p k besselap n returnsthezeros poles and gain of an order n Bessel analog lowpass filter prototype It returns the poles in the length n column vector p and the gain in scalar k z is an empty matrix because there are no zeros n must be less than or equal to 25 The transfer funct
318. in The tool box provides functions for each step of this process Classical IIR Filter Design Analog Lowpass Prototype Creation Frequency Transformation Discretization buttap cheblap besselap l p21 p p2hp pl bilinear ellipap cheb2ap lp2bp p2bs i mpi nvar Complete Design butter cheby1 cheby2 ellip bessel f Minimum Order Computation for Classical IIR Filter Design buttord cheblord cheb2ord ellipord Thebutter chebyl cheby2 andel li p functions are sufficient for many design problems and the lower level functions are generally not needed But if you do have an application where you need to transform the band edges of an analog filter or discretize a rational transfer function this section describes tools to do so 2 37 2 Filter Design 2 38 Analog Prototype Design This toolbox provides a number of functions to create lowpass analog prototype filters with cutoff frequency of 1 the first step in the classical approach to IIR filter design The table below summarizes the analog prototype design functions for each supported filter type plots for each type are shown in the IIR Filter Design section above Filter Type Analog Prototype Function Bessel ZaD bessel ap n Butterworth Tap buttap n Chebyshev type Zi Ds cheblap n Rp Chebyshev type I Z cheb2ap n Rs Elliptic Z ellipap n Rp Rs Frequency Transformation The
319. in the main axes display area Initially thenoi se signal covers up the bandlimited bl noise signal but you can see that both signals are displayed because the names of both signals are shown above the main axes display area EJ Signal Browser AEE Fie Options Window r Selection x1 0 3332 y1 0 39430174 2 oseese y2 2 8569391 dx 0 3334 dy 3 2512408 Save Rulers Panner 3 Click and drag in the Selection pop up menu to select the b noi se signal The main axes display area is redisplayed Now you can seethebl noi se signal superimposed on top of thenoi se signal Thesignals are displayed in different colors in both the main axes display area and the panner Notice 5 105 5 Interactive Tools that the color of the line in the Selection display changes to correspond to the color of the signal that you ve selected EJ Signal Browser AEE Fie Options Window Selection _ _ tala e e ac gt Real iA bist view IE corel Fouad Price sore Help blnoise Color noise blnoise Rulers e 47 x1 0 3332 y1 0 52671 2 0 6666 y2 0 610391 dx 0 3334 4 dy 0 084194 D 0 1 02 O27 704 05 06 sa o8 7 os Time Save Rulers Panner The signal that s displayed in the Selection pop up menu and in the Selection display is the active signal When you select Play or use the rulers the active signal is the one that is played or measured 4 T
320. in the passband and a stopband Rs dB down fromthe peak value in the passband It returns the filter coefficients in the lengthn 1 row vectorsb anda with coefficients in descending powers of z _ Bz bD b A z 1 a 2 z7 a n 1 z H z The cutoff frequency is the edge of the passband at which the magnitude response of the filter is Rp dB For elli p the cutoff frequency Wn is a number between 0 and 1 where 1 corresponds to half the sample frequency Nyquist frequency Smaller values of passband rippleRp and larger values of stopband attenuation Rs both lead to wider transition widths shallower rolloff characteristics If Wn is a two element vector Wn wl w2 ellip returns an order 2 n bandpass filter with passband wl lt lt w2 ellip b a ellip n Rp Rs Wn ftype designs a highpass or bandstop filter wheref type is e hi gh for a highpass digital filter with cutoff frequency Wn e stop for an order 2 n bandstop digital filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 With different numbers of output arguments el i p directly obtains other realizations of the filter To obtain zero pole gain form use three output arguments z p k ellip n Rp Rs Wn or z p k ellip n Rp Rs Wn ftype returns the zeros and poles in length n column vectorsz and p and the gain in the scalar k To obtain state space form use four output arguments A
321. inator ordersnb andna respectively the statement b a prony x nb na Parametric M odeling finds the numerator and denominator coefficients of an IHR filter whose impulse response approximates the sequence x prony implements the method described in Parks and Burrus 3 pgs 226 228 This method uses a variation of the covariance method of AR modeling to find the denominator coefficients a and then finds the numerator coefficients b for which the resulting filter s impulse response matches exactly the first nb 1 samples of x The filter is not necessarily stable but it can potentially recover the coefficients exactly if the data sequence is truly an autoregressive moving average ARMA process of the correct order NOTE The functions prony andstmcb described next are more accurately described as ARX models in system identification terminology ARMA modeling assumes noise only at the inputs while ARX assumes an external input prony andstmcb know the input signal it is an impulse for pr ony and is arbitrary for st mcb A model for the test sequence x from the earlier pc example using a third order IIR filter is b a prony x 3 3 b 1 1165 0 2181 0 6084 0 5369 1 0000 0 1619 0 4765 0 4940 4 13 4 Special Topics Thei mpz command shows how well this filter s impulse response matches the original sequence format long x impz b a 10 ans 1 11649535105007 1 11649535105007 0
322. ing message is displayed for noninteger n Warning Rounding order to nearest integer 6 25 blackman See Also References 6 26 bartlett boxcar chebwin hammi ng hanni ng kaiser triang Bartlett window Rectangular window Chebyshev window Hamming window Hanning window Kaiser window Triangular window 1 Oppenheim A V and R W Schafer Discr amp ee Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 boxcar Purpose Syntax Description Algorithm See Also References Rectangular window w boxcar n w boxcar 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 w ones n 1 bartlett Bartlett window blackman Blackman window chebwin Chebyshev window hammi ng Hamming window hanni ng Hanning window kaiser Kaiser window triang Triangular window 1 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 6 27 buttap Purpose Syntax Description Algorithm See Also References 6 28 Butterworth analog lowpass filter prototype z p k buttap n z p k buttap n returns the zeros poles and gain of an order n Butter worth analog lowpass filter prototype It returns the poles in the length n column vector p and the gain in scalar k z is an empty matrix because t
323. ing thebessel ap function 2 It converts the poles zeros and gain into state space form 3 It transforms thelowpass filter into a bandpass highpass or bandstop filter with desired cutoff frequencies using a state space transformation 4 It converts the state space filter back to transfer function or zero pole gain form as required See Also bessel ap Bessel analog lowpass filter prototype butter Butterworth analog and digital filter design chebyl Chebyshev type filter design passband ripple cheby2 Chebyshev type II filter design stopband ripple ellip Elliptic Cauer filter design 6 19 bilinear Purpose Syntax Description 6 20 Map variables using bilinear transformation zd pd kd bilinear z p k Fs zd pd kd bilinear z p k Fs Fp numd dend bilinear num den Fs numd dend bilinear num den Fs Fp Ad Bd Cd Dd bilinear A B C D Fs Ad Bd Cd Dd bilinear A B C D Fs Fp The bilinear transformation is a mathematical mapping of variables In digital filtering it is a standard method of mapping thes or analog plane into the z or digital plane It transforms analog filters designed using classical filter design techniques into their discrete equivalents The bilinear transformation maps the s plane into the z plane by A z HCS f coal z This transformation maps the jQ axis from Q co to repeatedly around the unit circle exp j from
324. ingS onrera rpa onena cece eee Saving and Discarding Changes to Preferences Settings Controls for Viewing and Measuring 2 005 ZOOM COMEKONS HA s daa hea koa a Adan yell D Gye weal Spa nee Si Rulef Controls senma ara Geshe obi CEE wesw bees Making Signal Measurements 2 0000e sees Using the Signal Browser Interactive Signal Analysis Opening the Signal Browser 0 000 e eens Basic Signal Browser Functions 00 ea eeaeee MENUS ape ere than teed Nae a ed ea ed oma le ed ZOOM GONONS oa pena bre iGiawaw ee eed sas bea Gees Ruler and Line Display Controls Hep Buttons a ss be ae ee oe Bs eat auh ey Ad tien ga ea tte Display Management Controls 0202000 ee Main Axes Display Area 00 0 cece eee eee Panne eco Satie dais ee able Det ee ee wag es Making Signal Measurements 00 000 e eee Viewing and Exploring Signals 0 0 0005 Selecting and Displaying a Signal Panner Display 00000 c cece ee eee Manipulating Displays 0000 e eee eee eee Working with Signals 000 c eee eee ee Saving Signal Data 0 0 2 e eee eee Using the Filter Designer Interactive Filter Design Opening the Filter Designer 00 ce cece eee ees vii Basic Filter Designer Functions 0c ceca eee 5 56 MIGNUS arren EA EE Beatles neg ali dain wad ems EENE eee 5 56
325. ingroots then uses zp2ss tofind a state space representation of the system Example system sos 1 A B C D A 10 8990 3 1463 9 8990 0 B 1 0 1 0 C 19 7980 D 2 Algorithm See Also sos2tf 0S2zp 2505 zp2sos Second order section to transfer function conversion Second order section to zero pole gain conversion State space to second order section conversion Zero pole gain to second order section conversion 6 279 sos2tf Purpose Syntax Description Algorithm 6 280 Second order section to transfer function conversion b a sos2tf sos sos2tf converts a second order section representation of a given system to an equivalent transfer function representation b a sos2tf sos returns the numerator coefficients b and denominator coefficients a of the transfer function that describes a discrete time system given by sos in second order section form The second order section format of H z is given by L L 1 2 l l bog bigz bagz H z H z Ok lk I 2k 7 k l A0k T Alk akz k 1 where L is the number of rows ofsos sos is an L by 6 matrix which contains the coefficients of each second order section stored in its rows boy b bzn 41 a 421 bo 2 bi2 bn ap anp an SOS ae R bot bi b2L AL UL aL Row vectors b anda contain the numerator and denominator coefficients of H z stored in descending powers of z _ B _ BOH b A z aD a alm H z
326. inite set of data Estimation of power spectra is useful in a variety of applications including the detection of signals buried in wide band noise The power spectral density PSD of a stationary random process x is related mathematically to the correlation sequence by the discrete time Fourier transform P E ty mel m This function of frequency has the property that its integral over a frequency band is equal to the power of the signal x in that band The PSD is a special case of the cross spectral density CSD function defined between two signals Xn and yp as P y gt Yme m As is the case for the correlation and covariance sequences the toolbox estimates the PSD and CSD because signal lengths are finite The various methods of PSD estimation can be identified as parametric or nonparametric One technique offered in the Signal Processing Toolbox is the popular nonparametric scheme developed by Welch 5 This is complemented by more modern nonparametric techniques such as the multitaper method MTM and the multiple signal classification MUSIC or agenvector EV method which is well suited for line spectra data made up of sinusoids The YuleWalker autoregressi ve AR method is a parametric method that estimates the autocorrelation function to solve for the AR model parameters The Burg method is another parametric spectral estimation method that minimizes the forward and backward linear prediction errors whil
327. ion is k s p s p s p n bessel ap normalizes the poles and gain so that at low frequency and high frequency the Bessel prototypeis asymptotically equivalent tothe Butterworth prototype of the same order 1 The magnitude of the filter is less than sqrt 1 2 at the unity cutoff frequency Q 1 H s Analog Bessel filters are characterized by a group delay that is maximally flat at zero frequency and almost constant throughout the passband The group delay at zero frequency is 2n 1 n 2 n bessel ap finds the filter roots from a look up table constructed using the Symbolic Math Toolbox bessel f Bessel analog filter design buttap Butterworth analog lowpass filter prototype cheblap Chebyshev type analog lowpass filter prototype cheb2ap Chebyshev type analog lowpass filter prototype ellipap Elliptic analog lowpass filter prototype Also see the Symbolic Math Toolbox User s Guide 1 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 228 230 6 15 besself Purpose Syntax Description 6 16 Bessel analog filter design b a besself n Wn b a besself n Wn ftype z p k besself A B C D besself besself designs lowpass bandpass highpass and bandstop analog Bessel filters Analog Bessel filters are characterized by almost constant group delay across the entire passband thu
328. ion mark symbol Y ou can then click on anything in the Signal Browser including menu items to find out what it is and how to use it Display Management Controls Array Signals Button Use this to enter a column index vector for a selected array signal All array signals start out with only the first column displayed Using the Signal Browser Interactive Signal Analysis The Array Signals button is enabled when at least one array signal is selected in SPTool 1 Click on Array Signals The Column Selection for Array Signals dialog box is displayed E Column Selection for Array Signals x Array Signals i as 1 3 Cancel OK All array signals that are selected in SPTool are shown in the list 2 Select a signal from the list 3 Typea column index vector for the selected signal Valid index vectors are of theform1 or1 3 or 1 3 5 Complex Signal Display U se to specify whether the Signal Browser plots the real part the imaginary part the magnitude or the angle of a complex signal This menu is enabled when at least one of the signal variables selected in SPTool is complex The Complex Display mode affects all of the variables in the current selection even those that are strictly real Click and drag to select the plotting mode Main Axes Display Area The Signals list in SPTool shows all signals in the current SPT ool session One or more signals may be selected The signal data of all selected signals are d
329. ion of an ideal desired filter these functions return a windowed inverse Fourier transform of that ideal filter Both use a Hamming window by default but they accept any window function See the Windows section of Chapter 4 for an overview of windows and their properties Standard Band FIR Filter Design firl fir1 implements the classical method of windowed linear phase FIR digital filter design It resembles the lIR filter design functions in that it is formulated todesign filters in standard band configurations lowpass bandpass highpass and bandstop 2 20 FIR Filter Design The statements n 50 Wn 0 4 b firl n Wn create row vector b containing the coefficients of the order n Hamming windowed filter This is a lowpass linear phase FIR filter with cutoff frequency Wn Wn is a number between 0 and 1 where 1 corresponds to the Nyquist frequency half the sampling frequency Unlike other methods here Wn corresponds to the 6 dB point For a highpass filter simply append the string hi gh tothe function s parameter list For a bandpass or bandstop filter specify Wn as a two element vector containing the passband edge frequencies append the string stop for the bandstop configuration b firl n Wn window uses the window specified in column vector wi ndow for the design The vector wi ndow must ben 1 elements long If you do not specify a window fir1 applies a Hamming window Kaiser Window Order Estim
330. ions R 1 R 2 R n a 2 R 2 R 2 R 1 R n 1 a 3 _ R 3 R n R n 1 R a n 1 R n 1 wherer R 1 R n 1 isthe input autocorrelation vector and R i denotes the complex conjugate of R i The algorithm requires O n2 flops and is thus much more efficient than the MATLAB command for largen However the evi nson function uses for low orders to provide the fastest possible execution Ipc Linear prediction coefficients prony Prony s method for time domain IHR filter design st mcb Linear model using Steiglitz M cBride iteration 1 Ljung L System Identification Theory for the User Englewood Cliffs NJ Prentice Hall 1987 Pgs 278 280 6 201 Ip2bp Purpose Syntax Description 6 202 Lowpass to bandpass analog filter transformation bt at p2bp b a Wo Bw At Bt Ct Dt p2bp A B C D Wo Bw p2bp transforms analog lowpass filter prototypes with a cutoff frequency of 1 rad sec into bandpass filters with desired bandwidth and center frequency The transformation is one step in the digital filter design process for the butter chebyl cheby2 andel lip functions p2bp can perform the transformation on two different linear system representations transfer function form and state space form In both cases the input system must be an analog filter prototype Transfer Function Form Polynomial bt at p2bp b a Wo Bw transforms an analog lowpa
331. ions H x Xa x Mb leads to the Yule Walker equations r 1 r 2 FOR a 2 r 2 r 2 1 a 3 _ r 3 r 2 r n r 2 r 1 a n 1 r n 1 wherer r 1 r 2 r n 1 is an autocorrelation estimate for x computed using xcorr The YuleWalker equations are solved in O n flops by the Levinson Durbin algorithm see evi nson The filter gain is given by g Ara so that m 1_ g X 1 X2 Z X M Z I 1 a 2 z a n 1 z in the least squares sense 6 213 Ipc See Also ar Compute autoregressive models of signals See System dentification Toolbox User s Guide levinson Levinson Durbin recursion prony Prony s method for time domain IHR filter design pyul ear Power spectrum estimate using Yule Walker AR method st mc b Linear model using Steiglitz McBride iteration References 1 J ackson L B Digital Filters and Signal Processing Second Ed Boston Kluwer Academic Publishers 1989 Pgs 255 257 6 214 max flat Purpose Syntax Description Generalized digital Butterworth filter design b a maxflat nb na Wn b maxflat nb sym Wn b a bl b2 maxflat nb na Wn maxflat nb na Wn design _flag b a maxflat nb na Wn iSalowpass Butterworth filter with numerator and denominator coefficients b anda of ordersnb andna respectively Wn isthe cutoff frequency at which the magnitude response of the filter is equal to 1 42 approx
332. ions of the filter To obtain zero pole gain form use three output arguments z p k butter n Wn or z p k butter n Wn ftype butter returns the zeros and poles in length n column vectorsz andp and the gain in the scalar k To obtain state space form use four output arguments A B C D butter n Wn or A B C D butter n Wn ftype wheredA 8 C andD are x n 1 Ax n Buln y n Cx n Du n and u is the input x is the state vector and y is the output Analog Domain b a butter n Wn s designs an order n lowpass analog Butterworth filter with cutoff frequency Wn It returns the filter coefficients in the length n 1 row vectors b anda in descending powers of s _ Bis _ B s 2 s 1 b n 1 H s 3j A s s 4 a 2 s a n 1 but t er S cutoff frequency Wn must be greater than 0 butter Examples If Wn is atwo element vector with wl lt w2 butter n Wn s returns an order 2 n bandpass analog filter with passband w1 lt lt w2 b a butter n Wn ftype s designs a highpass or bandstop filter wheref type is e hi gh for a highpass analog filter with cutoff frequency Wn e stop for an order 2 n bandstop analog filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 With different numbers of output arguments but ter directly obtains other realizations of the analog filter To obtain zero pole gain form usethree output argu
333. ions on Aerospace Electronic Systems AES 20 No 2 March 1984 Pgs 158 173 6 335 Zp2sos Purpose Syntax Description 6 336 Zero pole gain to second order section conversion sos zp2sos z p k sos zp2sos z p k order zp2sos converts a zero pole gain representation of a given system to an equivalent second order section representation sos zp2so0s z p k finds a matrixsos in second order section form equivalent to the zero pole gain system represented by input arguments z p and k Vectors z andp contain the zeros and poles of the system H z not necessarily in any order z z 1 z 2 2 Z 2 N p p0 p p 2 p p M H z k k s a scalar gain The zeros and poles must be real or come in complex conjugate pairs sos is an L by 6 matrix boy bu bza ap ay az bo2 12 bn ap a2 an SOS bor bi b2L aL AL aL whose rows contain the numerator and denominator coefficients b and a of the second order sections of H z L Sorbie pe t hipz bz z H no Ok Ik 2k 5 Ti aQk t4alkZ a2kZ k 1 The number of rows L of matrix sos is the maximum of the ceiling of N 2 and the ceiling of M 2 where N and M arethe lengths of z and p respectively Zp2sos Example Algorithm sos zp2sos z p k order specifies the order of the rows in sos where order is e down toorder the sections so the first row ofsos contains the poles closest to the unit circle
334. ipal discrete time model for this toolbox The transfer function model description for the z transform of a digital filter s difference equation is _ DU FQ bab 2 a l a 2 z alna 1 z 4 Y z X z Here the constants b i and a i are the filter coefficients and the order of the filter is the maximum of na and nb In MATLAB you store these coefficients in two vectors row vectors by convention one row vector for the numerator and one for the denominator See Filters and Transfer Functions on page 1 15 for more details on the transfer function form Linear System M odels Zero Pole Gain The factored or zero pole gain form of a transfer function is H a z _ k z 402z g2 Z 9g pZ pP p 2 z p n By convention MATLAB stores polynomial coefficients in row vectors and polynomial roots in column vectors In zero pole gain form therefore the zero and pole locations for the numerator and denominator of a transfer function reside in column vectors The factored transfer function gain k isa MATLAB scalar Thepoly androots functions convert between polynomial and zero pole gain representations For example a simple IHR filter is b 2 3 4 a 133 1 The zeros and poles of this filter are q roots b q 0 7500 1 1990 0 7500 1 1990 p roots a 1 0000 1 0000 0 0000 1 0000 0 0000 iT b 1 a 1 1 33 1 Signal Processing Basics
335. isplayed graphically in the main axes display area of the Signal Browser When there is only one signal displayed its properties are reflected in the display management controls and its measurements are displayed in the ruler display panel When more than onesignal is displayed select the line you want to focus on 5 45 5 Interactive Tools 5 46 When a signal is selected you can usethe ruler controls on the selected line see Making Signal Measurements on page 5 37 you can choose how to display the signal see Display Management Controls on page 5 44 and you can play the signal see Options Menu on page 5 43 The label of the selected signal line is displayed in the Selection pop up menu There are three ways to select a signal line in the Signal Browser e Click on the Selection pop up menu and drag to select the line to measure or e Move the mouse pointer over any point in the line in the main axes display and click on it or e Movethe mouse pointer over any point in the linein the panner and click on it See Selecting a line to measure on page 5 33 for details Axes Labels By default the x axis in the Signal Browser is labeled Ti me You can change the x axis label and add a y axis label using the Signal Browser settings panel in Preferences See Signal Browser Settings on page 5 24 Click and Drag Panning You can use the mouse to pan around the main axes display Click on
336. it circle e up to order the sections so the first row of sos contains the poles farthest from the unit circle default SS2SOS Example Algorithm Find a second order section form of a Butterworth lowpass filter A B C D butter 5 0 2 Sos 0S s2S0S s2505 A B C D 0 2451 0 2454 0 1 0000 0 5095 0 0 0647 0 1294 0 0647 1 0000 1 0966 0 3554 0 0809 0 1616 0 0807 1 0000 1 3693 0 6926 uses a four step algorithm to determine the second order section representation for an input state space system 1 It finds the poles and zeros of the system given by A B C andD 2 It uses the function zp2s0s which first groups the zeros and poles into complex conjugate pairs using thecp xpair function zp2sos then forms the second order sections by matching the pole and zero pairs according to the following rules a Match the poles closest to the unit circle with the zeros closest to those poles b Match the poles next closest to the unit circle with the zeros closest to those poles c Continue until all of the poles and zeros are matched s2s0s groups real poles into sections with the real poles closest to them in absolute value The same rule holds for real zeros It orders the sections according to the proximity of the pole pairs to the unit circle ss2sos normally orders the sections with poles closest to the unit circle last in the cascade You can tell ss2sos to order the sections in the reverse order b
337. ital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pg 227 6 37 cceps Purpose Syntax Description Algorithm 6 38 Complex cepstral analysis xhat cceps x xhat nd cceps x xhat nd xhatl cceps x cceps x n Cepstral analysis is a nonlinear signal processing technique that is applied most commonly in speech processing and homomor phic filtering 1 xhat cceps x returns the complex cepstrum of the assumed real sequence x The input is altered by the application of a linear phase term to have no phase discontinuity at z radians That is it is circularly shifted after zero padding by some samples if necessary to have zero phase at z radians xhat nd cceps x returns the number of samples nd of circular delay added tox prior to finding the complex cepstrum xhat nd xhat1 cceps x returns a second complex cepstrum computed using an alternate rooting algorithm in xhat 1 The alternate method 1 p 795 is useful for short sequences that can be rooted and donot have zeros on the unit circle For these signals xhat 1 can provide a verification of xhat cceps x n zeropadsx tolengthn and returns thelength n complex cepstrum of x cceps in its basic form is an M file implementation of algorithm 7 1 in 2 A lengthy Fortran program reduces to three lines of MATLAB code ho fF tC x logh log abs h sqrt 1 rcunwrap angle h y real if
338. ital filter design cheb2ap Chebyshev type analog lowpass filter prototype chebyl Chebyshev type filter design passband ripple ellipap Elliptic analog lowpass filter prototype 1 Parks T W and C S Burrus Digital Filter Design New York J ohn Wiley amp Sons 1987 Chapter 7 cheblord Purpose Syntax Description Chebyshev type filter order selection n Wn cheblord Wp Ws Rp Rs n Wn cheblord Wp Ws Rp Rs s cheblord selects the minimum order digital or analog Chebyshev type filter required to meet a set of filter design specifications Wp Passband corner frequency Wp the cutoff frequency has a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Ws Stopband corner frequency Ws is in the same units as Wp it has a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Rp Passband ripple in decibels This value is the maximum permissible passband loss in decibels The passband is 0 lt w lt Wp Rs Stopband attenuation in decibels This value is the number of decibels the stopband is down from the passband The stopband isWs lt w lt 1 Digital Domain n Wn cheblord Wp Ws Rp Rs returns the order n of the lowest order Chebyshev filter that loses no more than Rp dB in the passband and has at leastRs dB of attenuation in thestopband The passband runs from 0 toWp and the stopband
339. itude displays the magnitude of the frequency response of the currently selected filter s e Phase displays the phase of the frequency response e Group Delay displays the negative of the derivative of the phase response e Zeros and Poles displays the poles and zeros of the filter transfer function s and their proximity to the unit cirde e Impulse Response displays the response of the currently selected filter s to a discrete time unit height impulse at t 0 e Step Response displays the response of the currently selected filter s toa discrete time unit height step function You can customize the display characteristics of the magnitude and phase subplots using the Magnitude and Phase pop up menus The options include e Magnitude Scaling for the magnitude plot may be linear log or decibels e Phase Phase units may be degrees or radians You can also change the magnitude and phase display characteristics for the Filter Viewer using the Filter settings panel of the Preferences dialog in SPTool Frequency Axis Settings You can change frequency axis scaling and range parameters for plots in the Filter Viewer Click on the option in the Frequency Axis panel you want to edit and drag to select a value The options indude e Scale Scaling for the frequency axis may be linear or log e Range The range for the frequency axis may be 0 Fs 2 0 F s or Fs 2 F s 2 where Fs represents the filter s sampling frequency
340. kspace The Save Rulers dialog box is displayed 2 Typea variable name in the edit field and click OK Using SPTool Making Signal Measurements Usethe rulers to make measurements on a selected line which is a vector or a column of a matrix in the Signal Browser a filter responsein the Filter Viewer or a spectrum in the Spectrum Viewer To make a measurement 1 Select a line as described in Selecting a line to measure on page 5 33 2 Apply aruler tothe display as described in Ruler Control Buttons on page 5 35 3 Position a ruler where you want it in the main axes area by clicking and dragging it a Movethe mouse over the ruler 1 or 2 that you want to drag The hand cursor is displayed when you re over a ruler with the ruler number inside it 1 b Click and drag the ruler to where you want it on the signal Depending on which ruler control is selected you can drag theruler tothe right and left Vertical Track and Slope or up and down Horizontal As you drag a ruler the Rulers panel shows the current position of both rulers Depending on which ruler control is selected the following fields are displayed x1 y1 x2 y2 dx dy m You can also position a ruler by typing its x1 and x2 or yl and y2 values in the Rulers panel as described on page 5 35 Ruler Controls Vertical There are two vertical rulers called ruler 1 and ruler 2 When vertical rulers arein use the measurements displayed in the
341. l part For a system in zero pole form supply column vector arguments z and p to zplane zplane z p For a system in transfer function form supply row vectors b anda as arguments tozpl ane zpl ane b a In this casezp ane finds theroots ofb anda using ther oot s function and plots the resulting zeros and poles Zero Pole Analysis See Linear System Models on page 1 32 for details on zero pole and transfer function representation of systems 1 31 1 Signal Processing Basics Linear System Models 1 32 The Signal Processing Toolbox provides several models for representing linear time invariant systems This flexibility lets you choose the representational scheme that best suits your application and within the bounds of numeric stability convert freely to and from most other models This section provides a brief overview of supported linear system models and describes how to work with these models in MATLAB Discrete Time System Models The discrete time system models are representational schemes for digital filters MATLAB supports several discrete time system models e Transfer function e Zero pole gain form e State space form e Partial fraction expansion e Second order section form e Lattice structure form e Convolution matrices Transfer Function The transfer function is a basic z domain representation of a digital filter expressing the filter as a ratio of two polynomials It is the princ
342. lf n Wn ftype besself returns the zeros and poles in length n or 2 n column vectorsz and p and the gain in the scalar k To obtain state space form use four output arguments A B C D besself n Wn or A B C D besself n Wn ftype wheredA B C andD are x Ax Bu y Cx Du and u is the input x is the state vector and y is the output 6 17 besself Example Design a fifth order analog lowpass Bessel filter that suppresses frequencies greater than 10 000 rad sec and plot the frequency response of the filter using freqs b a besself 5 10000 freqs b a plot frequency response Frequency Response o 2 10 L L 10 10 10 10 Frequency radians 200 o o g a 200 10 10 10 10 Frequency radians Limitations Lowpass Bessel filters have a monotonically decreasing magnitude response as do lowpass Butterworth filters Compared to the Butterworth Chebyshev and elliptic filters the Bessel filter has the slowest rolloff and requires the highest order to meet an attenuation specification For high order filters the state space form is the most numerically accurate followed by the zero pole gain form The transfer function coefficient form is the least accurate numerical problems can arise for filter orders as low as 15 6 18 besself Algorithm besself performs a four step algorithm 1 t finds lowpass analog prototype poles zeros and gain us
343. lowpass FIR filter b n 1 is the filter length wo is the normalized cutoff frequency in the range between 0 and 1 where 1 corresponds to half the sampling frequency that is the Nyquist frequency dp is the maximum passband deviation from 1 passband ripple andds is the maximum stopband deviation from 0 stopband ripple b firclsl n wo dp ds high generates a highpass FIR filter b b firclsi1 n wo dp ds wt and b firclsl n wo dp ds wt high specify a frequency wt above which for wt gt wo or below which for wt lt wo the filter is guaranteed to meet the given band criterion This will help you design a filter that meets a passband or stopband edge requirement There are four cases e Lowpass 0 lt wt lt wo lt 1 the amplitude of the filter is within dp of 1 over the frequency rangeO lt w lt wt 0 lt wo lt wt lt 1 the amplitude of the filter is within ds of O over the frequency rangewt lt lt 1 e Highpass 0 lt wt lt wo lt 1 the amplitude of the filter is within ds of O over the frequency rangeO lt lt wt 0 lt wo lt wt lt 1 the amplitude of the filter is within dp of 1 over the frequency rangewt lt lt 1 6 147 firclsl1 6 148 b fircls1 n wo dp ds wp ws k generates a lowpass FIR filter b witha weighted function n 1 isthefilter length wo is the normalized cutoff frequency dp is the maximum passband deviation from 1 passband ripple andds is the maximum stopban
344. lowpass analog prototype poles zeros and gain using the cheb2ap function 2 It converts poles zeros and gain into state space form 3 Ittransforms thelowpass filter into a bandpass highpass or bandstop filter with desired cutoff frequencies using a state space transformation For digital filter design cheby2 usesbi linear toconvert the analog filter into a digital filter 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 or w1 and w2 It converts the state space filter back to transfer function or zero pole gain form as required bessel f Bessel analog filter design butter Butterworth analog and digital filter design cheb2ap Chebyshev type II analog lowpass filter prototype cheb2ord Chebyshev type II filter order selection chebyl Chebyshev type filter design passband ripple ellip Elliptic Cauer filter design Purpose Syntax Description Swept frequency cosine generator y chirp t f0 t1 f1 y chirp t f0 t1 f1 method y chirp t f0 t1 f1 method phi y chirp t f0 t1 f1 generates samples of a linear swept frequency cosine signal at the time instances defined in array t wheref 0 is the instantaneous frequency at time 0 and f 1 is the instantaneous frequency at timet 1 f 0 and f 1 are both in Hertz If unspecified f 0 is O t1 is 1 andf1 is 100 y
345. lter created with the default settings and assigns it a default nameoffi tn wheren is a unique sequential identifying digit Once the default filter is created you can useit as is or edit it with the Filter Designer You can rename it using Name from the Edit menu Edit Design Use the Filter panel s Edit Design button to make the Filter Designer active and edit a filter You can only edit filters whose filter type is desi gn that is filters created in SPTool you cannot edit filters imported into SPTool Select one or more filters from the Filters list and click the Edit Design button in the filter panel The Filter Designer displays the first of the selected filters The other selected filters can be edited one at a time by selecting them from the Filter pop up menu See Using the Filter Designer Interactive Filter Design on page 5 55 for a full description of Filter Designer functions and operations Using SPTool Applying a Filter Use the Apply Filter button to apply a filter to a selected signal This creates a new signal 1 Select onesignal from the Signals list and onefilter from the Filters list and click the Apply Filter button in the filter panel The Apply Filter dialog box is displayed E Apply Filter x E Apply Filter x Input Signal sig2 Drag to select the Input Signal sig2 m algorithm you want to el use i Algorithm filter Transposed Direct Form II 7 dathm fiter
346. lue for al pha is 0 5 Diagnostics If r is not an integer i nt erp gives the following error message Resampling rate R must be an integer See Also decimate Decrease the sampling rate for a sequence decimation interpl One dimensional data interpolation table lookup see the online MATLAB Function Reference resample Change sampling rate by any factor spline Cubic spline interpolation see the online MATLAB Function Reference upfirdn Upsample apply an FIR filter and downsample References 1 IEEE Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 Algorithm 8 1 6 183 intfilt Purpose Syntax Description Examples 6 184 Interpolation FIR filter design b intfilt r al pha b intfilt r n Lagrange b intfilt r alpha designs a linear phase FIR filter that performs ideal bandlimited interpolation using the nearest 2 nonzero samples when used on a sequence interleaved with r 1 consecutive zeros everyr samples It assumes an original bandlimitedness ofal pha times the Nyquist frequency The returned filter is identical to that used byi nterp b intfilt r n Lagrange orb intfilt r n l designs an FIR filter that performs n th order Lagrange polynomial interpolation on a sequence interleaved withr 1 consecutive zeros everyr samples b haslength n 1 r for n even and length n 1 r 1 forn odd Both types of filters are basically lowpass
347. lumns of e and their corresponding concentrations in vector v in the DPSS MAT file database dpss mat e It is not necessary to specify sequence length because the length of the sequence is determined by the number of rows of e e nw is the time bandwidth product that was specified when the sequence was created usingdpss status dpsssave nw e v returns Oif the save was successful and 1 if there was an error dpss Discrete prolate spheroidal sequences Slepian sequences dpssclear Remove discrete prolate spheroidal sequences from database dpssdir Discrete prolate spheroidal sequences database directory dpssload Load discrete prolate spheroidal sequences from database 6 109 ellip Purpose Syntax Description 6 110 Elliptic Cauer filter design b a ellip n Rp Rs Wn b a ellip n Rp Rs Wn ftype b a ellip n Rp Rs Wn s b a ellip n Rp Rs Wn ftype s z p k ellip A B C D ellip el lip designs lowpass bandpass highpass and bandstop digital and analog elliptic filters Elliptic filters offer steeper rolloff characteristics than Butterworth or Chebyshev filters but are equiripplein both the pass and stopbands In general elliptic filters meet given performance specifications with the lowest order of any filter type Digital Domain b a ellip n Rp Rs Wn designs an order n lowpass digital elliptic filter with cutoff frequency Wn Rp GB of ripple
348. m 5 7 order estimation 2 7 6 263 Butterworth 6 34 Chebyshev type 6 41 Chebyshev type 6 46 elliptic 6 117 in Filter Designer 5 65 5 68 order selection 2 7 in Filter Designer 5 65 5 68 order of filter 1 15 2 7 orthogonal windows in PSD estimates 3 16 oscillator voltage controlled 6 322 overlap add method FIR filter implementation 1 22 6 127 P panner 5 51 in Signal Browser 5 21 5 24 5 46 Panner check box in Preferences dialog box 5 24 parameters in Spectrum Viewer 5 90 5 91 5 93 inheriting in Spectrum Viewer 5 91 parametric modeling 4 10 6 190 applications 4 10 frequency domain based 4 16 summary 2 5 techniques 4 10 time domain based linear predictive coding 4 11 4 12 Steiglitz M cBride method 4 14 time domain based 4 11 Parks McClellan method FIR filter design 2 22 6 255 Parseval s relation 3 13 partial fraction 1 42 partial fraction expansion 1 40 defined 1 35 determining with residue 1 41 example 1 35 partial fraction form 1 35 6 271 passband equiripple 2 9 2 10 group delay 2 11 passband ripple setting in Filter Designer 5 62 passband zoom 5 32 Passband Zoom button 5 32 pburg 3 6 3 21 4 10 6 6 6 221 Peaks button Signal Browser 5 36 periodic sinc function 6 103 Se also Dirichlet function periodogram 3 6 modified 3 9 persistent mouse zooming 5 31 phase computing with angle 6 12 of Fourier transform of sequence 1 44 of frequency response 1 26 viewing in Filter Viewer 5 82 of transfer f
349. m for the signal in vector a This syntax uses the default values enfft min 256 length a e Fs 2 e window hanning nfft e noverlap length window 2 nfft specifies the FFT length that s pecgram uses This value determines the frequencies at which the discrete time F ourier transform is computed Fs isa scalar that specifies the sampling frequency wi ndow specifies a windowing function and the number of samples s pec gram uses in its sectioning of vector a noverlap is the number of samples by which the sections overlap Any arguments that you omit from the end of the input parameter list use the default values shown above Ifa is real specgr am computes the discrete time Fourier transform at positive frequencies only Ifn is even specgram returns nf ft 2 1 rows induding the zero and Nyquist frequency terms Ifn is odd specgramreturnsnfft 2 rows The number of columns in B is k fix n noverlap length wi ndow nover ap Ifa is complex s pec gr am computes the discrete time F ourier transform at both positive and negative frequencies In this case B isa complex matrix with nf f t specgram rows Time increases linearly across the columns of 8 starting with sample 1 in column 1 Frequency increases linearly down the rows starting at 0 B specgram a nfft usesthespecified FFT length nf ft in its calculations Specify nf ft as a power of 2 for fastest execution B f specgram a nfft Fs returns a vect
350. me domain analysis in Filter Viewer 5 74 time domain based modeling See parametric modeling tool box Control Systems Toolbox 1 35 6 181 6 300 I mage Processing Toolbox 6 93 6 173 6 217 Signal Processing Toolbox 1 2 Symbolic Math Toolbox 6 15 System Identification Toolbox 6 214 6 303 6 314 Track button for rulers 5 35 5 37 5 39 transfer function 1 32 1 35 1 40 1 42 coefficients 1 15 converting to state space 6 307 defined 1 15 derivation 1 15 estimate from input and output 6 311 estimating using Welch s method 3 14 factored form 1 33 for analog filter 1 41 representing in MATLAB 1 32 specifying in SPT ool 5 13 zero pole gain form 1 33 transform 4 33 chirp z transform CZT 4 33 6 89 discrete cosine 6 92 discrete Fourier 1 43 Hilbert 4 37 6 170 Index inverse discrete cosine 4 35 6 173 inverse discrete F ourier 6 175 transformations between system models 1 41 bilinear 2 42 6 20 frequency 2 38 6 202 6 205 6 207 6 209 transition band 2 23 transposed direct form I1 6 130 initial conditions 6 135 trend removing 6 101 triang 4 2 6 7 6 315 compared tobartl ett 6 13 example 4 2 triangular window 6 315 tripuls 6 2 6316 two dimensional operations autocorrelation 6 329 convolution 6 70 obtaining subsection 6 70 cross correlation 6 329 discrete F ourier transform 1 45 6 126 filtering 6 133 inverse discrete Fourier transform 1 45 6 176 two dimensional signal processing withf ft 2 and ifft2 1 45 U
351. ments z p k butter n Wn s or z p k butter n Wn ftype s returns the zeros and poles in length n or 2 n column vectorsz and p and the gain in the scalar k To obtain state space form use four output arguments A B C D butter n Wn s or A B C D butter n Wn ftype s whereda B C andD are x Ax Bu y Cx Du and u is the input x is the state vector and y is the output For data sampled at 1000 Hz design a 9th order highpass Butterworth filter with cutoff frequency of 300 Hz b a butter 9 300 500 high 6 31 butter The filter s frequency response is freqz b a 128 1000 Frequency Response of 9th Order Butterworth 0 100 200 300 Magnitude Response dB 400 L L L L L 0 50 100 150 200 250 300 350 Frequency Hertz 400 fi 450 500 0 T T i L L E 50 100 150 200 250 300 350 Frequency Hertz 400 fi 450 500 Design a 10th order bandpass Butterworth filter with a passband from 100 to 200 Hz and plot its impulse response or unit sample response 6 32 Wn 100 200 500 b a butter n Wn y t impz b a 101 stem t y n 5 0 2 0 15 0 1F 0 05f ost 0 05 0 1F 0 15F 0 2f 0 25 1 1 1 L L L 0 10 20 30 40 50 60 70 80 90 100 butter Limitations Algorithm See Also For high order filters the state space form is the most numerically accurat
352. metric modeling 4 12 Levinson Durbin recursion 4 12 6 201 line color in Filter Viewer 5 34 in Signal Browser 5 34 in Spectrum Viewer 5 34 line selection in Filter Viewer 5 33 5 34 in Signal Browser 5 33 5 34 in Spectrum Viewer 5 33 5 34 line style customizing in SPTool 5 21 in Filter Viewer 5 23 5 34 in Signal Browser 5 23 5 34 in Spectrum Viewer 5 23 5 34 Line Style Order edit box in Preferences dialog box 5 23 1 15 Index 1 16 linear phase 2 16 2 17 6 150 filter design 6 255 related characteristics 2 17 linear prediction coefficients 6 211 linear prediction modeling 4 11 linear predictive coding linear swept frequency cosine See chirp linear system models 1 32 linear system transformations 1 41 conversion chart 1 41 linear time invariant differential equations rep resented in state space form 1 40 linear trend removing from sequence 6 101 load 1 13 lowpass filter analog prototype design 2 6 and impulse invariance 2 41 Bessel 6 16 Butterworth 6 29 6 30 Chebyshev type 6 51 6 52 Chebyshev type II 6 56 6 57 elliptic 6 110 6 111 FIR design with window method 2 21 for decimation 6 94 for interpolation 6 182 ideal impulse response 2 18 translation of cutoff frequency 6 209 p2bp 2 5 2 39 6 10 6 202 example 2 40 p2bs 2 5 2 39 6 10 6 205 p2hp 2 5 2 39 6 10 6 207 p21 p 2 5 2 39 6 10 6 209 pc 2 5 4 10 6 8 6211 See also linear predictive coding Prony s method LPC Seelinear p
353. min Fmax Fs In this case vc o scales the frequency modulation range so values of x on the interval 1 1 map to oscillations of frequency on Fmi n Fmax If the input x is an array vco produces an array whose columns oscillate according to the columns of x See F FT Based Time F requency Analysis on page 4 26 for an example using thevco function 4 31 4 Special Topics Deconvolution 4 32 Deconvolution or polynomial division is the inverse operation of convolution Deconvolution is useful in recovering the input to a known filter given the filtered output This method is very sensitive to noise in the coefficients however so use caution in applying it The syntax for deconv is q r deconv b a where b is the polynomial dividend a is the divisor q is the quotient andr is the remainder Totry deconv first convolve two simple vectors a and b see Chapter 1 for a description of the convolution function a 1 2 3 b 4 5 6 c conv a b C 4 13 28 27 18 Now usedeconv todeconvolveb fromc q r deconv c a 0 0 0 0 0 See the System Identification Toolbox User s Guide for advanced applications of signal deconvolution Specialized Transforms Specialized Transforms In addition tothe discrete F ourier transform DFT described in Chapter 1 the Signal Processing Toolbox and the MATLAB environment together providethe following transform functions e The chirp z transf
354. minishes the side lobe interference or spectral leakage while increasing the width of spectral peaks With a suitable window such as Hamming Hanning or Kaiser overlap rates of about half the section length have been found to lower the variance of the estimate significantly The application of a Hanning window results in w hanning 256 Pxx abs fft w xn 1 256 2 abs fft w xn 129 384 2 abs fft w xn 257 512 2 abs fft w xn 385 640 2 abs fft w xn 513 768 2 a abs fft w xn 641 896 2 norm w 2 6 plot 0 255 256 Fs 10 l0g10 Pxx H Averaged Modified Periodogram 128 sample overlap Hanning window Power Spectru o a o fi ii 1 1 1 1 1 f 100 200 300 400 500 600 700 800 900 1000 Frequency Hz o Noticein this plot that the spectral peaks have widened and the noisefloor or level of the noise seems to be the flattest of any estimate so far This method of averaged modified periodograms is Welch s method of PSD estimation The functions psd andcsd provide control over all the parameters discussed so far FFT length window and amount of overlap in computing the PSD and CSD of one or two signals using Welch s method 3 9 3 Statistical Signal Processing 3 10 For a more detailed discussion of Welch s method of PSD estimation see Kay 1 and Welch 5 Power Spectral Density Function Thepsd function averages and scales the modi
355. mples around the unit circle parameterized byA 1 andW exp j pi M Thez transform on this contour is simply the DFT obtained by y czt x czt is faster than thef ft function for computing the DFT of sequences with certain odd lengths particularly long prime length sequences Try comparing the execution time for thef ft andczt functions for a sequence of length 1013 Specialized Transforms Discrete Cosine Transform The toolbox function dct computes the unitary discrete cosine transform or DCT for an input vector or matrix Mathematically the unitary DCT of an input sequence x is N 7 n 2n 1 k 1 7 y k w n x n Coss k 1 N n l where 1 n 1 w n IN The DCT is closely related to the discrete F ourier transform the DFT is actually one step in the computation of the DCT for a sequence The DCT however has better energy compaction properties with just a few of the transform coefficients representing the majority of the energy in the sequence The energy compaction properties of the DCT make it useful in applications such as data communications The function i dct computes the inverse DCT for an input sequence reconstructing a signal from a complete or partial set of DCT coefficients The inverse discrete cosine transform is N E n 2N 1 k 1 p x n L w k y k cs 5 n 1 N k 1 where 1 h k 1 w k JN 2 N i 2 lt k lt N 4 35 4 Special Topics B
356. n remez Parks McClellan optimal FIR filter design 1 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 Pgs 54 83 2 Oppenheim A V and R W Schafer Discre amp eTime Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 256 266 firrcos Purpose Raised cosine FIR filter design b firrcos n FO df Fs b firrcos n FO df Description firrcos n F0 df Fs returns an order n lowpass linear phase FIR filter with a raised cosine transition band The filter has cutoff frequency F 0 transition width df and sampling frequency Fs all in Hertz F0 must be between 0 and Fs 2 df must be small enough sothat f0 df 2 is between 0 andFs 2 The filter order n must be even firrcos n F0 df uses a default sampling frequency of Fs 2 Example Design an order 20 raised cosine FIR filter with cutoff frequency 0 25 of the Nyquist frequency and a transition width of 0 25 h firrcos 20 0 25 0 25 H fft h 1024 plot 0 1023 1024 2 abs H axis 0 1 0 1 2 grid 1 0 8F 3 0 6 oO 0 47 0 2 02 0 4 06 08 1 Frequency Normalized Remarks firrcos minimizes theintegral squared error in the frequency domain See Also firls Least square linear phase FIR filter design remez Parks McClellan optimal FIR filter design 6 155 freqs Purpose Syntax Description 6 156 Frequency response of analog filters h freqgs b a w
357. n f amp up lo fircls n f amp up lo0 design _flag b fircls n f amp up lo generates alengthn 1 linear phase FIR filter b The frequency magnitude characteristics of this filter match those given by vectors f andamp e f is a vector of transition frequencies in the range from 0 to 1 where 1 corresponds to half the sampling frequency the Nyquist frequency The first point of f must be 0 and the last point 1 The frequency points must be in increasing order e amp isa vector describing the piecewise constant desired amplitude of the frequency response The length of amp is equal tothe number of bandsin the response and should be equal to engt h f 1 e up and o arevectors with the same length asa mp They define the upper and lower bounds for the frequency response in each band fircls n f amp up o design_flag enables you to monitor the filter design wheredesign_flag canbe e trace for a textual display of the design table used in the design e plots for plots of the filter s magnitude group delay and zeros and poles e both for both the textual display and plots fircls Example Design an order 50 bandpass filter n 50 f 0 0 4 0 8 1 amp 0 1 0 up 0 02 1 02 0 01 lo 0 02 0 98 0 01 b fircls n f amp up lo plots plots magnitude response bas g g 0 8 0 85 0 9 0 95 1 Frequency NOTE Normally the lower value in the stopband will be specified as neg
358. n input sequence fftfilt breaks an input sequence x intolength L data blocks x t 4 L 2L 3L ceil nx L L 6 127 fftfilt See Also References 6 128 and convolves each block with the filter b by y ifft fft x i i L 1 nfft fft b nfft wherenf ft isthe FFT length fftfilt overlaps successive output sections by nb 1 points wherenb is the length of the filter and sums them L nb 1 2L nb 1 4 3L nb 1 fftfilt chooses the key parameters L andnfft in different ways depending on whether you supply an FFT length n and on the lengths of the filter and signal If you do not specify a value for n which determines FFT length fftfilt chooses these key parameters automatically elflength x gt length b fftfilt chooses values that minimize the number of blocks times the number of flops per FFT elflength b gt length x fftfilt uses a single FFT of length 2 nextpow2 length b length x 1 This essentially computes y ifft fft B nfft fft xX nfft If you supply a value forn fftfilt chooses an FFT length nf ft of 2 next pow2 n and a data block length of nfft ength b 1 1fn isless thanlength b fftfilt setsn tolength b conv Convolution and polynomial multiplication filter Filter data with a recursive IIR or nonrecursive FIR filter filtfilt Zero phase digital filtering 1 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Pren
359. n matrix v isthe kth eigenvector H is the conjugate transpose operator The eigenvectors used in the sum correspond to the smallest eigenvalues and span the noise subspace p is the size of the signal subspace 3 23 3 Statistical Signal Processing 3 24 The expression v e f is equivalent to a Fourier transform the vector e f consists of complex exponentials This form is useful for numeric computation because the FFT can be computed for each v and then the squared magnitudes can be summed The EV method weights the summation by the eigenvalues of the correlation matrix 1 y 2 l E ve ef ya k p 1 Thepmusi c function in this toolbox uses thes vd singular value decomposition function in the signal case and the ei g function for analyzing the correlation matrix and assigning eigenvectors to the signal or noise subspaces When s v d is used pmusi c never computes the correlation matrix explicitly but the singular values are the eigenvalues P a f Controlling Subspace Thresholds To provide user control over the assignments of eigenvectors to the signal and noise subspaces the pmus i c function accepts a threshold argument t hresh thresh isa two element vector where the first element is the number of eigenvectors spanning the signal subspace and the second element is a threshold test e ifthresh 2 lt 1 thenthresh 1 specifies the number of eigenvectors spanning the signal subspace In this case the values
360. n signal power level early in the cascade 2p2sos orders all zero sections according to the minimum of z and z 6 337 Zp2sos where z for i 1 2 are the zeros in the section References 1 and 2 provide detailed discussions of section ordering 4 zp2sos scales the sections so the maximum of the magnitude of the transfer function of the first N sections in cascade is less than 1 max N X o aieka N 1 L 1 lt 7 i l subject to the constraint that the overall gain k stays the same J L k 1 lok This scaling is an attempt to minimize overflow in some standard fixed point implementations of filtering See Also cplxpair Group complex numbers into complex conjugate pairs SOS2S5 Second order section to state space conversion sos2tf Second order section to transfer function conversion 0S2zp Second order section to zero pole gain conversion 552505 State space to second order section conversion References 1 Oppenheim A V and R W Schafer Discr amp ee Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 363 370 2 J ackson L B Digital Filters and Signal Processing Third Ed Boston Kluwer Academic Publishers 1989 Pgs 319 324 6 338 zp2ss Purpose Syntax Description Algorithm See Also Zero pole gain to state space conversion A B C D zp2ss Z p k zp2ss converts a zero pole gain representation of a given system to an equivalent state s
361. n vector z and the poles specified in column vector p in the current figure window The symbol 0 represents a zero and the symbol x represents a pole The plot includes the unit circle for reference Ifz andp arearrays zp ane plots the poles and zeros in the columns of z and p respectively in different colors You can override the automatic scaling of zp ane using axis xmin xmax ymin ymax or set gca ylim ymin ymax or set gca xlim xmin xmax after calling zpl ane This is useful in the case where one or a few of the zeros or poles have such a large magnitude that the others are grouped around the origin and are thus hard to distinguish zplane b a whereb anda are row vectors first usesroots tofind the zeros and poles of the transfer function represented by numerator coefficients b and denominator coefficients a hz hp ht zplane z p returns vectors of handles to the zerolines hz and the pole lines hp ht is a vector of handles to the axes unit circle line and to text objects which are present when there are multiple zeros or poles If there are no zeros or no poles hz or hp is set tothe empty matrix 6 341 zplane Examples Plot the poles and zeros of a 5th order Butterworth lowpass digital filter with cutoff frequency of 0 2 z p k butter 5 0 2 zpl ane z p Poles and Zeros of 5th Order Butterworth Lowpass Digital Filter Imaginary part fo On 0 5 F 7 J 1 0
362. nal Processing Toolbox and modify them as needed or create new functions to expand the functionality of the toolbox 1 Signal Processing Basics Representing Signals 1 4 The central data construct in MATLAB is the numeric array an ordered collection of real or complex numeric data with two or more dimensions The basic data objects of signal processing one dimensional signals or sequences multichannel signals and two dimensional signals are all naturally suited to array representation Vector Representation MATLAB represents ordinary one dimensional sampled data signals or sequences as vectors Vectors are 1 by n or n by 1 arrays where n is the number of samples in the sequence One way to introduce a sequence into MATLAB is to enter it as a list of elements at the command prompt The statement x 43 7 9 1 creates a simple five element real sequence in a row vector Transposition turns the sequence into a column vector X x resulting in X 4 3 7 9 1 Column orientation is preferable for single channel signals because it extends naturally to the multichannel case For multichannel data each column of a matrix represents one channel Each row of such a matrix then corresponds to a sample point A three channel signal that consists of x 2x and x r is y x 2 x x pi Representing Signals This results in 4 0000 3 0000 7 0000 9 0000 1 0000 14 0000 0000 0000 18 0000
363. names i g1 You can look at this signal in the Signal Browser by clicking on the View button under Signals You can look at the frequency content of the signal in the Spectrum Viewer by clicking on the Create button under Spectra and then clicking Apply in the Spectrum Viewer Basic SPTool Functions When you first open SPTool it contains no signals filters or spectra You can import signals filters and spectra into SPTool and you can also design filters using the Filter Designer and create spectra using the Spectrum Viewer You can also save and export data from SPTool and customize many properties of the SPTool environment The following figure shows the SPT ool window and its File and Help menus which are described below 1 Fin ES E r C me Fin Edi Hap Alnor Conted Seia ChbH einen ciH Proteercer Cem Cm Using SPTool The only button that is enabled is New Design you can always design a new filter The rest of the buttons are enabled when an appropriate object is listed and selected File Menu Open Session Select Open Session from the File menu toload a saved session file An SPTool session is saved in a file with an spt extension Import Select Import from the File menu to import a signal filter or spectrum into SPTool from either the workspace or from a file You can import variables from any MAT file into SPTool See I mporting Signals Filters and Spectra on page 5 8 and
364. nces use the final conditions fromx1 as initial conditions to filter x2 yl zf filter b a x1 y2 filter b a x2 zf Thefi ltic function generates initial conditions for f i ter fi ltic computes the delay vector to make the behavior of the filter reflect past inputs and outputs that you specify To obtain the same output delay valueszf as above usingfiltic zf filtic b a flipud y1 flipud x1 This can be useful when filtering short data sequences as appropriate initial conditions help reduce transient startup effects O ther Functions for Filtering Other Functions for Filtering In addition tof i ter there are several other functions in the Signal Processing Toolbox that perform the basic filtering operation These functions areupfirdn which performs FIR filtering with resampling fi tfilt which eliminates phase distortion in the filtering process and f f t fil t which performs the FIR filtering operation in the frequency domain Multirate Filter Bank Implementation The function upf i rdn alters the sampling rate of a signal by an integer ratio P Q It computes the result of the cascade of three systems 1 upsampling zero insertion by integer factor p 2 filtering by FIR filter h and 3 downsampling by integer factor q x n y n rH Hig For example to change the sample rate of a signal from 44 1 kHz to 48 kHz we first find the smallest integer conv
365. nd 6 268 resample points of the sequence x can cause inaccuracies in y at its end points The following two plots illustrate this side effect of r esampl e x 1 10 9 1 1 y resampl e x 3 2 plot 1 19 x 0 28 2 3 1 y o0 x 10 1 1 2 10 y resample x 3 2 plot 1 19 x 0 28 2 3 1 y 0 Edge effects very noticeable Edge effects not so noticeable 12 10 os 10 i x 8 E 8 OB BO 6 6 KA K amp 4 amp kS 4 amp e 2 iS original 2t amp ES Qo O O resampled e e 0 0 g 0 5 10 15 20 0 5 10 15 20 Diagnostics If p or q are not positive integers r esampl e gives the appropriate error message P must be a positive integer Q must be a positive integer If x is not a vector r esampl e gives the following error message Input X must be a vector 6 269 resample See Also deci mate Decrease the sampling rate for a sequence decimation firl Window based finite impulse response filter design standard response interp Increase sampling rate by an integer factor interpolation interpl One dimensional data interpolation table lookup see the online MATLAB Function Reference intfilt Interpolation FIR filter design aiser Kaiser window spline Cubic spline interpolation see the online MATLAB Function Reference upfirdn Upsample apply an FIR filter and downsample 6 270 residuez Purpose
366. nda in descending powers of s B s _ bs b b ACS sP a 1 4 4a nF1 H s Cutoff frequency is the frequency at which the magnitude response of the filter is Rp dB For cheby1 the cutoff frequency Wn must be greater than 0 cheby1 Examples If Wn is atwo element vector Wn wl w2 withwl lt w2 then chebyl n Rp Wn s returns an order 2 n bandpass analog filter with passband w1 lt lt w2 b a chebyl n Rp Wn ftype s designs a highpass or bandstop filter wheref type is e high for a highpass analog filter with cutoff frequency Wn e stop for an order 2 n bandstop analog filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 You can supply different numbers of output arguments for cheby1 to directly obtain other realizations of the analog filter To obtain zero pole gain form use three output arguments z p k chebyl n Rp Wn s or z p k chebyl n Rp Wn ftype s returns the zeros and poles in length n or 2 n column vectorsz andp and the gain in the scalar k To obtain state space form use four output arguments A B C D chebyl n Rp Wn s or A B C D chebyl n Rp Wn ftype s whered B C andD are defined as x Ax Bu y Cx Du and u is the input x is the state vector and y is the output For data sampled at 1000 Hz design a 9th order lowpass Chebyshev type filter with 0 5 dB of ripple in the passband and a cutof
367. ndow Parks McClellan optimal FIR filter design Parks McClellan optimal FIR filter order estimation 6 5 6 Reference 6 6 Transforms czt Chirp z transform dct Discrete cosine transform DCT df t mt x Discrete Fourier transform matrix fft fft2 fftshift hilbert idct ifft ifft2 One dimensional fast Fourier transform Two dimensional fast Fourier transform Rearrange the outputs of the FFT functions Hilbert transform Inverse discrete cosine transform One dimensional inverse fast Fourier transform Two dimensional inverse fast Fourier transform Statistical Signal Processing cohere corrcoef COV csd pburg pmt m pmusi c Estimate magnitude squared coherence function between two signals Correlation coefficient matrix Covariance matrix Estimate the cross spectral density CSD of two signals Power spectrum estimate using the Burg method Power spectrum estimate using the multitaper method MTM Power spectrum estimate using MUSIC eigenvector method Statistical Signal Processing psd Estimate the power spectral density PSD of a signal using Welch s method pyul ear Power spectrum estimate using Yule Walker AR method tfe Transfer function estimate from input and output xcorr Cross correlation function estimate xcorr2 Two dimensional cross correlation XCOV Cross covariance function estimate equal to mean removed cross correlation
368. ndy vectors nover ap isthe number of samples by which the sections overlap Any arguments that you omit from the end of the parameter list use the default values shown above Ifx isreal cohere estimates the coherence function at positive frequencies only in this case the output Cxy is a column vector of length nf ft 2 1 for nfft evenand nfft 1 2 forn odd Ifx ory is complex cohere estimates the coherence function at both positive and negative frequencies and Cxy has length nfft 6 65 cohere 6 66 Cxy cohere x y nfft usestheFFT length nf ft in estimating the power spectrum for x Specify nf ft as a power of 2 for fastest execution Cxy f cohere x y nfft Fs returns a vector f of frequencies at which the function evaluates the coherence Fs is the sampling frequency f is the same size asCxy Sop ot f Cxy plots the coherence function versus properly scaled frequency Fs has no effect on the output Cxy it is a frequency scaling multiplier Cxy cohere x y nfft Fs window specifies a windowing function and the number of samples per section of the vectors x andy If you supply a scalar for window cohere uses a Hanning window of that length The length of the window must be less than or equal tonf ft cohere zero pads the sections if the window length exceeds nf ft Cxy cohere x y nfft Fs window noverlap overlaps the sections of x by noverl ap Samples You can use the empty matrix to specify the de
369. ng on the PSD method computation parameters you choose Choosing Computation Parameters The Spectrum Viewer lets you control the PSD computation parameters of the selected spectrum Different parameters are available depending on which method of PSD computation you choose Set these parameters from the Parameters panel as illustrated in the following steps 5 93 5 Interactive Tools 5 94 1 Click on the Method pop up menu and drag to select one of the following methods Burg FFT MTM MUSIC Welch YuleAR Appropriate parameter selections are displayed for each method you choose 2 Modify the appropriate parameters When a parameter is in a pop up menu click on the parameter label and drag to select a value from the menu When a parameter is in an edit box type the value or variable into the box You can also modify the parameters by using Inherit from to copy the parameters of another spectrum in SPTool See Inherit from on page 5 91 for details 3 If you change your mind you can discard changes you make by clicking Revert 4 Toapply the modified parameters click Apply The new parameters are applied to the selected spectrum the Spectrum Viewer recalculates the spectral density function and displays the modified spectrum Computation Methods and Parameters You can choose from seven PSD computation methods Each method has its own set of parameters This section shows the Paramete
370. ng thei mpz function Type in a new value to change the time response length Magnitude Axis Scaling Specifies the scaling units for the magnitude y axis in the Filter Viewer Scaling units can be linear log or decibels Click in the pop up menu and drag to select a different scaling Phase Units Specifies the phase units for the phase response plot Phase units can be degrees or radians Click in the pop up menu and drag to select a different phase unit Frequency Axis Scaling Specifies the scaling units for the frequency x axis in the Filter Viewer Scaling units can be linear or log Click in the pop up menu and drag to select a different scaling 5 26 Using SPTool Frequency Axis Range Specifies the numerical range for the frequency x axis in the Filter Viewer Scaling options are 0 Fs 2 0 Fs or Fs 2 Fs 2 Click in the pop up menu and drag to select a different frequency range Rulers Click in the check box to display checked or hide unchecked the ruler buttons and the ruler panel in the Filter Viewer See Ruler Controls on page 5 32 for details on using the rulers in the Filter Viewer Stay in Zoom mode After Zoom Click in the check box to enable checked or disable unchecked zoom persistencein the Filter Viewer See Zoom Controls on page 5 30 for details on zoom controls in the Filter Viewer Filter Viewer Tiling Settings The Filter Viewer Tiling preferences let you cha
371. ngetheway the F ilter Viewer displays the analysis plots Fis sas Tiling C Herbi m Helmi C Weba l rid C Haimona 1 bea r Click the radio button to select how the plots are tiled in the display area Options are 2 by 3 Grid 3 by 2 Grid Vertical 6 by 1 Grid and Horizontal 1 by 6 Grid This specifies how the plots are arranged when all six plot options are turned on When fewer options are turned on the plots are displayed as symmetrically as possible 5 27 5 Interactive Tools 5 28 Filter Designer Settings The Filter Designer preferences let you set key filter configuration and plot parameters j Poskeiences foe OP Tiel a Fl eas ti itsts sS S Fr Depia gre bees T Audst esky ria via l Shain fsrads Au Foca FFT Length Specifies the number of points used to calculate a filter s frequency response Type in a new value or variable name to change the FFT length Display grid lines Turns plot grid lines on checked or off unchecked Auto Design initial value Specifies the default setting for the Auto Design check box in the Filter Designer When the Filter Designer is first launched the Auto Design check box will have the same setting checked or unchecked as the Auto Design initial value check box Stay in Zoom mode After Zoom Turns persistent zooming on and off as described in Zoom Controls on page 5 30 Using SPTool Plug Ins Settings The Plug Ins preference
372. ngth and sidelobe height parameters computes a Chebyshev window n 51 Rs 40 sidelobe height in decibels w chebwi n n Rs stem w Length 51 Chebyshev Window a fo 0 8F 0 6 til ne 5 10 15 20 25 30 35 40 45 Sample Number As shown in the plot the Chebyshev window has large spikes at its outer samples Plot the frequency response to see the equiripples at 40 dB Wf fregqz w 1 512 2 plot f 20 log1l0 abs W sum w grid Chebyshev Window Magnitude Response Normailzed Magnitude dB 80 i 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized Frequency Nyquist 1 For a detailed discussion of the characteristics and applications of the various window types see Oppenheim and Schafer 2 pgs 444 462 and Parks and Burrus 3 pgs 71 73 4 9 4 Special Topics 4 10 Parametric Modeling Parametric modeling techniques find the parameters for a mathematical model describing a signal system or process These techniques use known information about the system to determine the model Applications for parametric modeling include speech and music synthesis data compression high resolution spectral estimation communications manufacturing and simulation The toolbox parametric modeling functions operate with the rational transfer function model Given appropriate information about an unknown system impulse or frequency
373. ngthn 1 row vectors b anda with coefficients in descending powers of z _ Bz _ DELZ e NEE AZ 14 a 2 z b a nt z A z Cutoff frequency is the beginning of the stopband where the magnitude response of the filter is equal to Rs dB For cheby2 the cutoff frequency Wn is a number between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Larger values of stopband attenuation Rs lead to wider transition widths shallower rolloff characteristics If Wn is atwo element vector Wn wl w2 cheby2 returns an order 2 n bandpass filter with passband wl lt lt w2 cheby2 b a cheby2 n Rs Wn ftype designs a highpass or bandstop filter wheref type is e hi gh for a highpass digital filter with cutoff frequency Wn e stop for an order 2 n bandstop digital filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 With different numbers of output arguments cheby2 directly obtains other realizations of the filter To obtain zero pole gain form use three output arguments z p k cheby2 n Rs Wn or z p k cheby2 n Rs Wn ftype returns the zeros and poles in length n column vectors z andp and the gain in the scalar k To obtain state space form use four output arguments A B C D cheby2 n Rs Wn or A B C D cheby2 n Rs Wn ftype whered B C andD are x n 1 Ax n Bu n y n Cx n Du n and u is the input x is t
374. nly a finite segment of the infinite length random process c xcorr x y returns the cross correlation sequence in a length 2N 1 vector wherex andy arelength N vectors c xcorr x isthe autocorrelation sequence for the vector x Wherex isan N by P matrix c xcorr X returns a matrix with 2N 1 rows whose P 2 columns contain the cross correlation sequences for all combinations of the columns of X By default xcorr computes raw correlations with no normalization For a length N vector N ml 1 Xn 1Yn m 1 m20 Cxy m n 0 cyx m m lt 0 xCcorr The output vector has elements given by c m Cy m N m 1 2N 1 The correlation function requires normalization to estimate the function properly c xcorr x y option specifies a scaling option where option is e biased for biased estimates of the cross correlation function 1 Cxy biased m N Cxy m e unbiased for unbiased estimates of the cross correlation function Cxy unbiased m Cxy m aes N ml e coeff to normalize the sequence so the autocorrelations at zero lag are identically 1 0 e none tousethe raw unscaled cross correlations default See reference 1 for more information on the properties of biased and unbiased correlation estimates c lags xcorr x y wherex andy arelengthN vectors returns the cross correlation sequence in a length 2N 1 vector and the output lags in the vector N 1 N 1 That is the maxim
375. nputsp andt hr esh can determinethenumber of noise eigenvectors in one of three ways e lfthresh lt 1 orifitis unspecified the number of eigenvectors spanning the signal subspace will be equal top p must be an integer satisfying 0 lt p lt n wheren is thedimension of the eigenvectors This dimension n is the column length in the data matrix case the matrix size in the correlation matrix case or the window length for signal vectors The value of thresh is unused Ifp gt n thresh must beat least 1 t hresh is used as the multiplier to determine an absolute threshold for splitting the eigenvalues between the signal and noise subspaces ARS thresh min A Ak Vk belong to noise subspace Ifthresh lt 1 there will be no noise eigenvectors This case is not allowed and gives the following error message Noise subspace dimension cannot be zero Whenp lt n andthresh 2 1 p specifies the maximum number of signal eigenvectors However the threshold test specified byt hresh can also take eigenvectors from the signal subspace and assign them to the noise subspace This example analyzes a signal vector xx assuming that two real signals are present in the signal subspace In this case the dimension of the signal subspace is 4 because each real sinusoid is the sum of two complex exponentials nn 0 199 xx 0S 0 257 pi nn sin 0 2 pi nn 0 01 randn size nn PP ff pmusic xx 4 This example analyzes the same sign
376. ns the complex modulus magnitude abs x sqrt real x 2 imag x 2 If x isa MATLAB string abs returns the numeric values of the ASCII characters in thestring The display format of the string changes the internal representation does not This function is part of the standard MATLAB environment Calculate the magnitude of the FFT of a sequence t 0 99 100 time vector x sin 2 pi 15 t sin 2 pi 40 t signa y fft x compute DFT of x m abs y magnitude Plot the magnitude f O length y 1 length y 100 frequency vector plot f m angle Phase angle 6 11 angle Purpose Syntax Description Example Algorithm See Also 6 12 Phase angle p angle h p angle h returnsthephaseangles in radians of the elements of complex vector or array h The phase angles lie between r and z For complex sequence h x iy meP the magnitude and phase are given by m abs h p angle h Toconvert back to the original h from its magnitude and phase i sqrt 1 h m exp i p This function is part of the standard MATLAB environment Calculate the phase of the FFT of a sequence t 0 99 100 time vector x sin 2 pi 1l5 t sin 2 pi 40 t signal y fft x compute DFT of x p unwrap angle y phase Plot the phase f O length y 1 length y 100 frequency vector plot f p angle can be expressed as angle x imag log x atan2
377. nstantaneous phase angle You can calculate the instantaneous frequency using di f f as described in the online MATLAB Function Reference 4 38 References References Kay S M Modern Spectral Estimation Englewood Cliffs NJ Prentice Hall 1988 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 Pratt W K Digital mage Processing New York J ohn Wiley amp Sons 1991 4 39 4 Special Topics 4 40 Interactive Tools SPTool An Interactive Signal Processing Environment 5 2 UsingSPTool 0 002 5 4 Using the Signal Browser Interactive Signal Analysis 5 42 Using the Filter Designer Interactive Filter Design 5 55 Using the Filter Viewer Interactive Filter Analysis 5 74 Using the Spectrum Viewer Interactive PSD Analysis 5 88 Example Generation of Bandlimited Noise 5 100 5 Interactive Tools SPTool An Interactive Signal Processing Environment The Signal Processing Toolbox includes an interactive graphical user interface GUI called SPTool for performing digital signal processing tasks SPT ool provides an easy to use interface to many of the most important toolbox functions With it you can use the mouse and on screen controls to import view and measure digital signals design view and implement digital filters
378. nt matrix C corrcoef X C corrcoef X Y corrcoef returns a matrix of correlation coefficients calculated from an input matrix whose rows are observations and whose columns are variables If C cov X thencorrcoef X isthe matrix whose element i j is CUS yC DCG j C corrcoef X isthe zeroth lag of the covariance function that is the zeroth lag of xcov x coeff packed into a square array corrcoef i j C corrcoef X Y isthesameascorrcoef X Y that is it concatenates X andy in the row direction before its computation corrcoef removes the mean from each column before calculating the results See thexcorr function for cross correlation options This function is part of the standard MATLAB environment cov Covariance matrix mean Average value see the online MATLAB Function Reference median Median value see the online MATLAB Function Reference std Standard deviation see the online MATLAB Function Reference xcorr Cross correlation function estimate xcov Cross covariance function estimate equal to mean removed cross correlation COV Purpose Syntax Description Algorithm See Also Covariance matrix c cov x c cov Xx y cov computes the covariance matrix Ifx isa vector c is a scalar containing the variance For an array where each row is an observation and each column a variable cov X is the covariance matrix di ag cov X iS a vector of variances for
379. ntents on page 5 9 Loading Variables from Disk Toimport variables from a MAT file on disk first list the file s variables in the File Contents list Then select the variables to be imported into SPTool 1 Click the From Disk radio button You can either enter a MAT file name in the MAT file Name field or click Browse to open the file listing and select a MAT file Type the exact name of the file you want toimport into the MAT file Name field and press Tab or Enter Return on Macintosh or Click Browse and then find and select the file you want to import using the File Search window Click OK The data from the file you selected is displayed in the File Contents list You can now import one or more variables from the File Contents list into SPTool see below Importing Workspace Contents and File Contents Once you ve loaded the contents of the workspace or a file into the Workspace Contents or File Contents list you can select one or more variables from the list to import into SPTool You can import a variable as a signal parameter a 5 9 5 Interactive Tools 5 10 filter parameter or a spectrum parameter You can alsoimport a variable whose value represents a sampling frequency or other design parameter Depending on whether you re importing a signal a filter or a spectrum you can customize different parameters before you import the data into SPTool In each case however the general procedure for s
380. ntiator and Hilbert FIR filters since the operation of these filters depends heavily on their phase response filtfilt isan M filethat uses thef ilter function In addition tothe forward reverse filtering it attempts to minimize startup transients by adjusting initial conditions to match the DC component of the signal and by prepending several filter lengths of a flipped reflected copy of the input signal fftfilt FF T based FIR filtering using the overlap add method filter Filter data with a recursive IIR or nonrecursive FIR filter filter2 Two dimensional digital filtering 1 Oppenheim A V and R W Schafer Discr amp ee Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 311 312 filtic Purpose Syntax Description Find initial conditions for a transposed direct form I filter implementation z filtic b a y x z filtic b a y z filtic b a y x finds the initial conditions z for the delays in the transposed direct form II filter implementation given past outputs y and inputs x The vectors b anda represent the numerator and denominator coefficients respectively of the filter s transfer function The vectors x andy contain the most recent input or output first and oldest input or output last x x 1 x 2 x 3 x nb y y 1 y 2 3 4 na wherenb isl ength b 1 the numerator order and na isl ength a 1 the denominator order If engt
381. o Digital Transformation Function Transformation Impulse invariance numd dend impinvar num den Fs Bilinear transform zd pd kd bilinear z p k Fs Fp numd dend bilinear num den Fs Fp Ad Bd Cd Dd bilinear At Bt Ct Dt Fs Fp Impulse Invariance The toolbox function i mpi nvar creates a digital filter whose impulse response is the samples of the continuous impulse response of an analog filter This function only works on filters in transfer function form For best results the analog filter should have negligible frequency content above half the sampling frequency because such high frequency content is aliased into lower bands upon sampling mpulse invariance works for some lowpass and bandpass filters but is not appropriate for highpass and bandstop filters 2 41 2 Filter Design 2 42 Design a Chebyshev type filter and plot its frequency response bz az i mpinvar b a 2 freqz bz az 0 r r r r al S RNN L L L i 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 Magnitude Response dB 200 T T 200F 4 400b 3 Phase degrees 600F 4 4 00 1 L L L L t 4 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 Impulse invariance retains the cutoff frequencies of 0 1 Hz and 0 5 Hz Bilinear Transformation The bilinear transformation is a nonlinear mapping of the continuo
382. o Electroacoust Vol AU 15 J une 1967 Pgs 70 73 6 68 conv Purpose Syntax Description Example Algorithm See Also Convolution and polynomial multiplication c conv a b conv a b convolves vectors a andb The convolution sum is N 1 c n 1 alk 1 b n k k 0 where N is the maximum sequence length The series is indexed from n 1 and k 1 instead of the usual n and k because MATLAB vectors run from 1 ton instead of from 0 to n 1 The convolution ofa 1 2 3 andb 4 5 6 is c conv a b i 4 13 28 27 18 This function is part of the MATLAB environment It is an M file that uses the filter primitive conv computes the convolution operation as FIR filtering with an appropriate number of zeros appended to the input conv2 Two dimensional convolution convmt x Convolution matrix convn N dimensional convolution see the online MATLAB Function Reference deconv Deconvolution and polynomial division filter Filter data with a recursive IIR or nonrecursive FIR filter resi duez z transform partial fraction expansion xcorr Cross correlation function estimate 6 69 conv2 Purpose Syntax Description Examples 6 70 Two dimensional convolution C conv2 A B conv2 A B shape a 1 C conv2 A B computes the two dimensional convolution of matrices A and B If one of these matrices describes a two dimensional FIR filter the other matrix is filtered in two dim
383. o convert the analog filter into a digital filter 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 or w1 and w2 It converts the state space filter back to transfer function or zero pole gain form as required bessel f Bessel analog filter design butter Butterworth analog and digital filter design cheblap Chebyshev type analog lowpass filter prototype cheblord Chebyshev type filter order selection cheby2 Chebyshev type II filter design stopband ripple ellip Elliptic Cauer filter design 6 55 cheby2 Purpose Syntax Description 6 56 Chebyshev type II filter design stopband ripple b a cheby2 n Rs Wn b a cheby2 n Rs Wn ftype b a cheby2 n Rs Wn s b a cheby2 n Rs Wn ftype s z p k cheby2 A B C D cheby2 cheby2 designs lowpass highpass bandpass and bandstop digital and analog Chebyshev type II filters Chebyshev type II filters are monotonic in the passband and equiri pple in the stopband Type 11 filters do not roll off as fast as type filters but are free of passband ripple Digital Domain b a cheby2 n Rs Wn designs an order n lowpass digital Chebyshev type II filter with cutoff frequency Wn and stopband rippleks dB down from the peak passband value It returns the filter coefficients in thele
384. o hear the active signal select Play from the Options menu 5 To hear the other signal select it as in step 3 above and then select Play from the Options menu again You can also select the signal by dicking on it in the main axes display area 5 106 Example Generation of Bandlimited N oise Compare Spectra of Both Signals You can get an idea of the frequency content of the two signals by displaying their power spectra using the Spectrum Viewer as described below 1 Reactivate SPTool by selecting it from the Window menu of the Signal Browser 2 Click onthenoise vector signal in the Signals list of SPTool to select it 3 Click Create in the Spectra panel The Spectrum Viewer is activated and a spectrum object spect 1 corresponding to the noi se signal is created in the Spectra list The spectrum is not computed or displayed yet 4 Click Apply in the Spectrum Viewer to compute and displays pect1 The spectrum of thenoi se signal is displayed in the main axes display area E Spectrum Viewer AEE Fie Options Window Selection spect Color p ae Signal noise Selection spect Rulers 5000 by 1 real v A Fs 5000 Vertical Horizontal Parameters 4 be Method wach a1 wi 834 38094 Nett 1024 en y1 0 64819683 win 256 A ka F 2 eea RS T 2 1665 0391 y2 2 0961961 Overlap 0 dx 830 07812 Detrending none E 3 dy 1 4480093 Scaling Unbiased T Conf Int EZ A ye i 3
385. o normalize the output of f f t sothat a unit sinusoid in the time domain corresponds to unit amplitude in the frequency domain To produce a normalized discrete time F ourier transform in this manner use Pn abs fft x 2 length x fft is a built in MATLAB function When the sequence length is a power of two f f t uses a high speed radix 2 fast Fourier transform algorithm The radix 2 FFT routine is optimized to perform a real FFT if the input sequence is purely real otherwise it computes the complex FFT This causes a real power of two FFT to be about 40 faster than a complex FFT of the same length When the sequence length is not an exact power of two a separate algorithm finds the prime factors of the sequence length and computes the mixed radix discrete F ourier transforms of the shorter sequences See Also The execution time for f f t depends on the sequence length If the length of a sequence has many prime factors the function computes the FFT quickly if the length has few prime factors execution is slower For sequences whose lengths are prime numbers f f t uses the raw and slow DFT algorithm For this reason it is usually better to use power of two FF Ts if this is supported by your application F or example on one machine a 4096 point real FFT takes 2 1 seconds and a complex FFT of the same length takes 3 7 seconds The FFTs of neighboring sequences of length 4095 and 4097 however take 7 seconds and 58 seconds res
386. o obtain approximately independent estimates of the power spectrum and then combines them to yield an estimate This estimate exhibits more degrees of freedom and allows for easier quantification of the bias and variance trade offs compared to conventional periodogram methods Many conventional spectral estimates use a single taper or window with some irretrievable loss of information at the beginning and the end of the series In the multitaper method additional tapers are used to recover some of the lost information This brief discussion of the multitaper method provides an intuitive look at the algorithm to assist in determining when to use it For a more detailed and thorough explanation see Percival and Walden 3 The simple parameter for the multitaper method is the time bandwidth product NW This parameter is a resolution parameter directly related tothe number of tapers used to compute the spectrum There are always 2 NW 1 tapers used to form the estimate This means that as NW increases there are more estimates of the power spectrum and the variance of the estimate decreases H owever the bandwidth of each taper is also proportional to NW so Spectral Analysis as NW increases each estimate exhibits more spectral leakage i e wider peaks and the overall spectral estimate is more biased F or each data set there is usually a value for NW that allows an optimal trade off between bias and variance Using pmt
387. o show the new filter s magnitude response dod i ei Fraquency Using the Filter Designer Interactive Filter Design Filter Design O ptions When the Minimum Order option is disabled you can specify parameters that define characteristics unique to certain filter types e For equiripple and least squares filters the weights for error minimization e For Kaiser window filters the cutoff frequency and B parameter of the Kaiser window Order Selection for FIR Filter Design As described earlier the FIR filter design options available through the Filter Designer call thetoolbox functionsremez firls andfir1 tncalculating filter order the Filter Designer uses the same guidelines as the toolbox functions e The Equiripple FIR design option calls ther emezord order estimation function to determine a filter order that meets a set of specifications In some cases r emezor d underestimates the filter order n If the filter does not appear to meet the given specifications using Minimum Order order selection deselect Minimum Order and manually specify a slightly larger order n 1 orn 2 e The Least Squares FIR design option calls the toolbox function fi rls Because the toolbox does not provide an order estimation function for use with f i rI s you cannot use the Minimum Order option with the Least Squares FIR method e The Kaiser Window FIR design option callsk ai ser ord theorder estimation function which sometimes underestimat
388. od pyul ear Power spectrum estimate using Yule Walker AR method specgram Time dependent frequency analysis spectrogram tfe Transfer function estimate from input and output psd References 1 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 399 419 2 Welch P D TheUseof Fast F ourier Transform for the Estimation of Power Spectra A Method Based on Time Averaging Over Short Modified Periodograms IEEE Trans Audio Electroacoust Vol AU 15 J une 1967 Pgs 70 73 3 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 311 312 6 243 pulstran Purpose Syntax Description 6 244 Pulse train generator pulstran t d func pulstran t d func pl p2 pulstran t d p Fs pulstran t d p ba Sa SA a pulstran generates pulse trains from continuous functions or sampled prototype pulses y pulstran t d func generates a pulse train based on samples of a continuous function f unc wherefunc is e gauspuls for Gaussian modulated sinusoidal pulse generator e rectpuls for sampled aperiodic rectangle generator e tripuls for sampled aperiodic triangle generator pulstran isevaluated engt h d times and returns the sum of the evaluations y func t d 1 func t d 2 The function is evaluated over the range of argument val
389. oefficient vectors a and b to create the filtered data vector y When x isa matrix filter operates on the columns of x When x is an N dimensional array filter operates on the first non singleton dimension y zf filter b a x returns the final values of the states in the vector zt filter b a x zi specifies initial state conditions in the vector zi The size of the initial final condition vector is max l ength b length a 1 zi orzf can also be an array of such vectors one for each column of x ifx isa matrix If x is a multidimensional array fi ter works across the first nonsingleton dimension of x by default filter b a x zi dim works across the dimension di m of x Set zi to empty to get the default initial conditions filter works for both real and complex inputs filter Example Algorithm Find and graph the 100 point unit impulse response of a digital filter x 1 zeros 1 100 b a butter 12 400 1000 y filter b a x stem y 0 4 0 37 4 0 27 4 0 1 l J bo Pye 0 1F Jd 20 4 0 2 0 n 0 60 80 100 120 filter isa built in MATLAB function fi ter is implemented as a transposed direct form II structure x m where n 1 is the filter order 6 131 filter Diagnostics See Also References 6 132 The operation of fi ter at sample m is given by the time domain difference equations for y and the states z ym b
390. of signal processing tasks These toolbox functions area specialized extension of the MATLAB computational and graphical environment Filtering and FFTs Two of the most important functions for signal processing are not in the Signal Processing Toolbox at all but are built in MATLAB functions e filter applies a digital filter to a data sequence e fft calculates the discrete F ourier transform of a sequence The operations these functions perform are the main computational workhorses of classical signal processing Both are described in this chapter The Signal Processing Toolbox uses many other standard MATLAB functions and language features including polynomial root finding complex arithmetic matrix inversion and manipulation and graphics tools Signals and Systems The basic entities that toolbox functions work with are signals and systems The functions emphasize digital or discrete signals and filters as opposed to analog or continuous signals The principal filter type the toolbox supports is the linear time invariant digital filter with a single input and a single output You can represent linear time invariant systems using one of several models such as transfer function state space zero pole gain and second order section and convert between representations Signal Processing Toolbox Central Features Key Areas Filter Design and Spectral Analysis In addition toits corefunctions the toolbox provides rich cust
391. of the filter is displayed with a solid linein the main axes display area The resulting filter is an order 78 bandpass equiripple filter 5 103 5 Interactive Tools Apply the Filter to a Signal In this step you apply the filter tothe signal in SPTool Thenew filtered signal is automatically created in SPTool 1 Activate SPTool from the Window menu in the Filter Designer 2 Click to select the signal noi se vector from the Signals list and click to select the filter named f i I t1 desi gn from the Filters list as shown below es 3 Click Apply to apply the filter f i t1 tothesignal noise The Apply Filter dialog box is displayed 4 Namethe new signal by clicking in the Output Signal field and typing bl noise 5 Click OK The filter is applied to the selected signal The new filtered signal bl noise vector is displayed in the Signals list 5 104 Example Generation of Bandlimited N oise View and Play the Signals You can view the time domain information of the signals using the Signal Browser You can also play the signals if your computer has audio output capabilities In this step you ll display both signals in the Signal Browser and select and play first one signal and then the other 1 Shift click on thenoi se andb noi se signals in the Signals list of SPTool to select both signals 2 Click View in the Signals panel The Signal Browser is activated and both signals are displayed
392. of the state space equations and combining them shows the equivalence of state space and transfer function form Y z HU where H z C zI A B D Don t be concerned if you are not familiar with the state space representation of linear systems Some of the filter design algorithms use state space form internally but do not require any knowledge of state space concepts to use them successfully If your applications use state space based signal processing extensively however consult the Control System Toolbox for a comprehensive library of state space tools Partial Fraction Expansion Residue Form Each transfer function also has a corresponding partial fraction expansion or residue form representation given by Ate ere 5 cae SO 5 k k 2 z 1b kim n z a z 1 p l z 1 p n z provided H z has no repeated poles Here n is the degree of the denominator polynomial of the rational transfer function b z a z If ris a pole of multiplicity Sr then H z has terms of the form 0 Rae a eR AC pz a p pie Theresi duez function in the Signal Processing Toolbox converts transfer functions to and from the partial fraction expansion form The z on the end of residuez stands for z domain or discrete domain resi duez returns the poles in a column vector p the residues corresponding tothe poles in a column vector r and any improper part of the original transfer function in a row vector k residuez determines
393. omizable support for the key areas of filter design and spectral analysis It is easy to implement a design technique that suits your application design digital filters directly or create analog prototypes and discretize them Toolbox functions also estimate power spectral density and cross spectral density using either parametric or nonparametric techniques Chapters 2 and 3 respectively detail toolbox functions for filter design and spectral analysis There are functions for computation and graphical display of frequency response as well as functions for system identification generating signals discrete cosine chirp z and Hilbert transforms lattice filters resampling time frequency analysis and basic communication systems simulation Graphical User Interface GUI The power of the Signal Processing Toolbox is greatly enhanced by its easy to use graphical user interface The GUI provides an integrated set of interactive tools for performing a wide variety of signal processing tasks These tools enable you to use the mouse and menus to manipulate a rich graphical environment for signal viewing filter design and implementation and spectral analysis Extensibility Perhaps the most important feature of the MATLAB environment is that it is extensible MATLAB lets you create your own M files to meet numeric computation needs for research design or engineering of signal processing systems Simply copy the M files provided with the Sig
394. onditions filter Function Implementation and Initial Conditions filter is implemented as a transposed direct form I1 structure x m y m where n 1 is the filter order This is a canonical form that has the minimum number of delay elements At sample m f i ter computes the difference equations ym b x m z m 1 z m b 2 x m z2 m 1 a 2 y m Zn 2 m b n 1 x m Z _4 m 1 a n 1 y n Zn 1 M b n x m a n y m In its most basic form f i Iter initializes the delay outputs z 1 i 1 n 1 to 0 This is equivalent to assuming both past inputs and outputs are zero Set the initial delay outputs using a fourth input parameter tof i ter or access the final delay outputs using a second output parameter y zf filter b a x zi Access to initial and final conditions is useful for filtering data in sections especially if memory limitations are a consideration Suppose you have collected data in two segments of 5000 points each xl randn 5000 1 two random sequences to x2 randn 5000 1 serve as simulated data Perhaps the first sequence x1 corresponds to the first 10 minutes of data and the second x2 toan additional 10 minutes The whole sequence is x x1 x2 Ifthere is not sufficient memory to hold the combined sequence filter the subsequences x1 and x2 one at atime To ensure continuity of the 1 17 1 Signal Processing Basics 1 18 filtered seque
395. onfiguration selected in the Type pop up menu and thestate of the Minimum Order check box Specifications Parameters Automatic Order Selection When the Minimum Order box is checked all of the filter designs except Least Squares FIR display the same set of parameters in the Specifications panel The order for the Least Squares FIR design cannot be automatically computed F or lowpass and highpass band configurations these parameters include the passband edge frequency F p the stopband edge frequency Fs the passband ripple Rp and the stopband attenuation Rs For bandpass and bandstop configurations the parameters include the lower and upper passband edge frequencies F p1 and F p2 the lower and upper stopband edge frequencies Fs1 and Fs2 the passband ripple Rp and the stopband attenuation Rs Frequency values arein Hertz and ripple and attenuation values arein dB Specifications Parameters Manual Order Selection When the Minimum Order box is not checked an Order parameter for setting the filter order appears bel ow it and each filter design displays a unique set of parameters in the Specifications panel These are shown in the table below where Wp and Ws are the weights for the passband and stopband Beta is the Kaiser window B parameter Fc is the cutoff frequency and F 3db is the 3 dB frequency 5 59 5 Interactive Tools Low pass Highpass Bandpass Bandstop Equiripple FIR Fp Fs Wp Ws Fp Fs Wp W
396. ons this algorithm produces spurious large but finite zeros ss2zp interprets these large zeros as infinite ss2zp finds the gains by solving for the first nonzero Markov parameters 6 299 ss2zp See Also References 6 300 pzmap ss2tf tf2ss zp2ss Pole zero map of LTI system Control System T ool box User s Guide State space to transfer function conversion Transfer function to state space conversion Zero pole gain to state space conversion 1 Laub A J and B C Moore Calculation of Transmission Zeros Using QZ Techniques Automatica 14 1978 Pg 557 stmcb Purpose Syntax Description Linear model using Steiglitz M cBride iteration b a stmcb x nb na b a stmcb x u nb na b a stmcb x nb na niter b a stmcb x u nb na niter b a stmcb x nb na niter ai b a stmcb x u nb na niter ai Steiglitz M cBride iteration is an algorithm for finding an IIR filter with a prescribed time domain impulse response It has applications in both filter design and system identification parametric modeling b a stmcb b a stmcb that given u as b a stmcb b a stmcb niter is 5 b a stmcb b a stmcb x nb na finds the coefficients b anda of the system b z a z with approximate impulse response x exactly nb zeros and exactly na poles x u nb na findsthesystem coefficientsb anda of thesystem input has x as output x an
397. or f of frequencies at which the function computes the discrete time F ourier transform Fs has no effect on the output B it is a frequency scaling multiplier B f t specgram a nfft Fs returns frequency andtimevectorsf andt respectively t is a column vector of scaled times with length equal to the number of columns of B t j is the earliest time at which the j th window intersects a t 1 is always equal to 0 B specgram a nfft Fs window specifies a windowing function and the number of samples per section of thex vector If you supply a scalar for wi ndow specgr am uses a Hanning window of that length The length of the window must beless than or equal tonf f t s pec gr am zero pads the sections if the length of the window exceeds nf f t B specgram a nfft Fs window noverlap overlaps the sections of x by noverl ap samples You can use the empty matrix to specify the default value for any input argument For example B specgram x 10000 is equivalent to B specgram x but with a sampling frequency of 10 000 Hz instead of the default 2 Hz specgram with no output arguments displays the scaled logarithm of the spectrogram in the current figure window using imagesc t f 20 logl0 abs b axis xy colormap j et 6 285 specgram Algorithm 6 286 Theaxis xy mode displays the low frequency content of the first portion of the signal in the lower left corner of the axes specgramusesfs tolabel the axes
398. or of grid points that have been linearly interpolated over each specified frequency band by cr emez gf determines the frequency grid at which the response function must be evaluated This is the same data returned by cremez in thef grid field of theopt structure w iS a vector of real positive weights one per band used during optimization w is optional in the call tocr emez if not specified it is set to unity weighting before being passedto fresp dh and dw arethe desired complex frequency response and band weight vectors respectively evaluated at each frequency in grid gf e pl p2 are optional parameters that may be passed to fresp Additionally a preliminary call is made to fresp todetermine the default symmetry property sym This call is made using the syntax sym fresp defaults n f w pl p2 The arguments may be used in determining an appropriate symmetry default as necessary The function pri vat e owpass m may be useful as a template for generating new frequency response functions An extended version of the Remez exchange method is implemented for the complex case This exchange method obtains the optimal filter when the equiripple nature of the filter is restricted tohaven 2 extremals When it does not converge the algorithm switches to an ascent descent algorithm that takes over to finish the convergence to the optimal solution See the references for further details 6 81 cremez Di
399. order Duplicate frequency points are allowed and in fact can be used to design a filter exactly the same as those returned by thefir1 andfi r2 functions with a rectangular or boxcar window a is a vector containing the desired amplitude at the points specified inf The desired amplitude function at frequencies between pairs of points f k f k 1 for k odd is the line segment connecting the points f k a k and f k 1 a k 1 The desired amplitude function at frequencies between pairs of points f k f k 1 for k even is unspecified These are transition or don t care regions e f anda arethe same length This length must be an even number firls The relationship between thef anda vectors in defining a desired amplitude response is Desired amplitude A response a 10L OS t a Normalized occ chums soco boooo frequency f 0 0 01 02 03 04 05 06 0 7 0 8 0 9 1 0 Nyquist eoccce Don t care transition regions b firls n f a w uses the weights in vector w to weight the fit in each frequency band The length of w is half the length off anda sothereis exactly one weight per band b firls n f a ftype and b firls n f a w ftype specify a filter type wheref type is e hil bert for linear phase filters with odd symmetry type lll and type IV The output coefficients in b obey the relation b k b n 2 k k 1 n 1 This class of filters includes the Hilbert transformer
400. orm CZT useful in evaluating the z transform along contours other than the unit circle The chirp z transform is also more efficient than the DFT algorithm for the computation of prime length transforms and it is useful in computing a subset of the DFT for a sequence e The discrete cosine transform DCT closely related to the DFT The DCT s energy compaction properties are useful for applications such as signal coding e TheHilbert transform which facilitates the formation of the analytic signal The analytic signal is useful in the area of communications particularly in bandpass signal processing Chirp z Transform The chirp z transform or CZT computes the z transform along spiral contours in the z plane for an input sequence Unlike the DFT the CZT is not constrained to operate along the unit circle but can evaluate the z transform along contours described by z AW 1 0 M 1 where A is the complex starting point W is a complex scalar describing the complex ratio between points on the contour and M is the length of the transform 4 33 4 Special Topics 4 34 One possible spiral is A 0 8 exp j pi 6 W 0 995 exp j pi 05 M 91 z A W 0 M 1 zplane z 0 54 he Ke z x z x a ms st 2 x E i or E se i g ox 0 5 T T 1H x x Jd Real part czt x M W A computes the z transform of x on these points An interesting and useful spiral set ism evenly spaced sa
401. ound the upper half of the unit circle sow contains n points between O and z It is best although not necessary to choose a value for n that is an exact power of two because this allows fast computation using an FFT algorithm If you do not specify a value for n it defaults to 512 h f freqz b a n Fs specifies a positive sampling frequency Fs in Hertz It returns a vector f containing the actual frequency points between 0 and Fs 2 at which it calculated the frequency response f is of length n h w freqz b a n whole and h f freqz b a n whole Fs usen points around the whole unit circle from 0 to 22 or from OtoFs h freqz b a w returnsthe frequency response at the frequencies in vector w These frequencies must be between 0 and 2r freqz Example Algorithm h freqz b a f fs returns the frequency response at the frequencies in vector f where the elements of f are between 0 andFs freqz with no output arguments plots the magnitude and phase response versus frequency in the current figure window f reqz works for both real and complex input systems Plot the magnitude and phase response of a Butterworth filter b a butter 5 0 2 freqz b a 128 T B 50F n 8 100 cc o 1507 ge 5 200 w 2 250 L L L L L i L L L 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 Normalized frequency Nyquist 1 0 100 1 oO P 200F F B g 300F oO amp
402. out the center of the displayed signal You can click repeatedly on one or more buttons to continue to change the scale in one or both axes When you zoom in the x axis horizontal scaling the Y limits vertical scaling of the main axes are not changed Similarly when you zoom in the y axis the X limits of the main axes are not changed Full View Click oncetorestorethe displayed signal toits full samplesizein both axes Mouse Zoom Click once to activate zoom mode The cursor changes to a crosshair Y ou can either zoom in without specifying a zoom window or you can use a zoom rectangle to select a specific zoom window In either case the x and y axis are automatically adjusted to display the selected signal e Tozoom in without specifying a zoom window click on the plot The position of the crosshair is the center of a zoom operation that halves both the x and y axis limits e To use a zoom rectangle click where you want the rectangle to begin drag the mouse diagonally to where you want it to end and release the mouse button e Toget out of mouse zoom mode without zooming in or out click on the Mouse Zoom button again Zoom Persistence Mouse zooming can either be onetime or persistent e Onetime zooming is activated when you click the Mouse Zoom button It automatically turns itself off after you click in the display area and the zoom operation occurs This is the default for all the tools e Persistent zooming is also
403. ow Select a window from the pop up menu ee Overlap I 3 Typein a value Detrending Select one of the following from the pop up menu none linear mean Scaling Select one of the following from the pop up menu Unbiased Peaks by Fs Conf Int Check to compute a confidence interval and type in a value see Setting Confidence Intervals on page 5 98 Yule AR For the YuleAR method you can specify the following parameters Order Baisan A bishi fair E El Type in a value Pee bag Nfft Typein a value Corr Matrix Check if selected signal is a correlation matrix l Calm 5 97 5 Interactive Tools 5 98 Setting Confidence Intervals By default the Spectrum Viewer does not compute confidence intervals for spectral density You can enablethe computation of confidenceintervals for the Welch and MTM methods by following these steps 1 Click the Conf Int check box so that it is selected 2 Typea value for the confidence level in the Conf Int edit box This value must be a scalar between 0 and 1 3 Click Apply NOTE Confidence intervals are only reliable for nonoverlapping sections Saving Spectrum Data After creating a spectrum in SPTool you can export spectrum information to the workspace or to disk using Export from the File menu in SPTool The spectrum information is stored in a structurethat you can access toretrievethe spectral power and frequency d
404. owpass filter to a digital filter usingi mpi nvar witha sampling frequency of 10 Hz b a butter 4 0 3 s bz az impinvar b a 10 bz 1 0e 006 0 0000 0 1324 0 5192 0 1273 0 az 1 0000 3 9216 5 7679 3 7709 0 9246 6 177 impinvar Algorithm See Also References 6 178 i mpi nvar performs the impulse invariant method of analog to digital transfer function conversion discussed in reference 1 1 It finds the partial fraction expansion of the system represented byb anda 2 It replaces the poles p by the polesexp p Fs 3 It finds the transfer function coefficients of the system from the residues from step 1 and the poles from step 2 bilinear Map variables using bilinear transformation p2bp Lowpass to bandpass analog filter transformation p2bs Lowpass to bandstop analog filter transformation p2hp Lowpass to highpass analog filter transformation p2lp Lowpass to lowpass analog filter transformation 1 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 Pgs 206 209 impz Purpose Syntax Description Impulse response of digital filters h t impz b a h t impz b a n h t impz b a n Fs impz b a impz h t impz b a computes the impulse response of the filter with numerator coefficients b and denominator coefficients a i mpz chooses the number of samples and returns the response in column vector h
405. pace representation It forms state space models from the zeros poles and gains of systems in transfer function form A B C D zp2ss Z p k findsasingleinput multiple output state space representation x Ax Bu y Cx Du given a system in factored transfer function form _ 2s _ k s z 1 s z 2 s z n H s P s s p D s p 2 8 p n Column vector p specifies the pole locations and array z thezerolocations with as many columns as there are outputs The gains for each numerator transfer function are in vector k TheA B C andD matrices are returned in controller canonical form nf values may be used as placeholders in Z if some columns have fewer zeros than others zp2ss for single input systems groups complex pairs together into two by two blocks down the diagonal of the A matrix This requires the zeros and poles to be real or come in complex conjugate pairs ss2tf State space to transfer function conversion SS2Zp State space to zero pole gain conversion tf2ss Transfer function to state space conversion tf2zp Transfer function to zero pole gain conversion zp2tf Zero pole gain to transfer function conversion 6 339 zp2tf Purpose Syntax Description Algorithm See Also 6 340 Zero pole gain to transfer function conversion num den zp2tf Z p k zp2tf forms transfer function polynomials from the zeros poles and gains of a system in factored form
406. parse If you specify an empty matrix for the second argument pburg generates the following error message Model order must be given empty not allowed pburg See Also References pc pmt m pmusic prony psd pyulear Linear prediction coefficients Power spectrum estimate using the multitaper method MTM Power spectrum estimate using MUSIC eigenvector method Prony s method for time domain IIR filter design Estimate the power spectral density PSD of a signal using Welch s method Power spectrum estimate using Yule Walker AR method 1 Marple S L Digital Spectral Analysis Englewood Cliffs NJ Prentice Hall 1987 Chapter 7 6 223 pmtm Purpose Syntax Description 6 224 Power spectrum estimate using the multitaper method MTM Pxx pmt mx Pxx pmt m x nw Pxx pmtm x nw nf ft Pxx f pmtmx nw nfft Fs Pxx f pmtm x nw nfft Fs method Pxx Pxxc f pmtm x nw nfft Fs method Pxx Pxxc f pmtm x nw nfft Fs method p Pxx Pxxc f pmtm x e v nfft Fs method p Pxx Pxxc f pmtm x dpss_params nfft Fs method p pmt m estimates the power spectral density PSD of the real time series x using the multitaper method MTM described in 1 Pxx pmtm x nw estimatesthePSD usingnw asthetime bandwidth product for the discrete prolate spheroidal sequences Slepian sequences that are used as data windows The default for nw is 4 oth
407. pass highpass and bandstop configurations usefi r1 b fir2 n f m returns row vector b containing then 1 coefficients of an order n FIR filter The frequency magnitude characteristics of this filter match those given by vectorsf and m e f isavector of frequency points in the range from 0 to 1 where 1 corresponds to half the sampling frequency the Nyquist frequency The first point of f must be 0 and the last point 1 The frequency points must be in increasing order e mis a vector containing the desired magnitude response at the points specified inf e f and m must be the same length e Duplicate frequency points are allowed corresponding to steps in the frequency response Usepl ot f m to view the filter shape The output filter coefficients b are ordered in descending powers of z b z b0 bQ z b n Dz b fir2 n f m window uses the window specified in column vector wi ndow for the filter design The vector wi ndow must ben 1 elements long If no window is specified f i r2 employs a Hamming window 6 141 fir2 Algorithm b fir2 n f m npt and b fir2 n f m npt window specify the number of points npt for the grid onto whichf i r2 interpolates the frequency response with or without awi ndow specification b fir2 n f m npt lap and b fir2 n f m npt lap window specify the size of the region ap that fir2 inserts around duplicate frequency points with or without a wi ndow speci
408. pburg x p nfft Fs returnsPxx the power spectrum estimate andf req a vector of frequencies at which the PSD was estimated x is theinput signal p is the model order for the all pole filter and nf f t isthe FFT length defaults to 256 if not specified Fs specifies the signal s sampling frequency which is used to scale the output frequency vector f req Iftheinput signal is real valued f req ranges from OtoFs 2 1ftheinput signal is complex freq ranges from 0 tofs Fs defaults to 2 if not specified Pxx freg a pburg returns vector a of filter coefficients for the all pole filter model pburg plots the power spectral density in the first available figure window This example analyzes a sequence x n assuming that two real signals are present in the signal subspace In this case the model order must be four or larger because each real sinusoid is the sum of two complex exponentials 6 221 pburg Diagnostics 6 222 Experience shows that taking a larger model order than the minimum seems to work better Create xx as a signal vector nn 0 199 randn seed 0 xx 0S 0 257 pi nn sin 0 2 pi nn 0 01 randn size nn PP ff aa pburg xx 7 7th order model plot ff pi 10 log10 PP grid Plot the pole locations 30 T 0 5 1 1 5 2 2 5 3 3 5 The first input argument must be a full vector otherwise pbur g generates the following error message Input signal cannot be s
409. pe of signals in the passband that is there is no phase distortion Thefunctionsfirl fir2 firls remez fircls fircls1 andfirrcos all design type and II linear phase FIR filters by default Both f i ri s andr emez design type III and IV linear phase FIR filters given a hil bert or differentiator flag cremez can design any type of linear phase filter and nonlinear phase filters as well NOTE Because the frequency response of a typeI filter is zero at the Nyquist rate high frequency f i r1 does not design type II highpass and bandstop filters For odd valued n in these cases f i r1 adds 1 to the order and returns a type filter Windowing Method Consider the ideal or brick wall digital lowpass filter with a cutoff frequency of wg rad sec This filter has magnitude 1 at all frequencies with magnitudeless 2 18 FIR Filter Design than g and magnitude 0 at frequencies with magnitude between wp and z Its impulse response sequence h n is T OO h n Z Hodo eJON Gey 0 since 20 n 20 Jr 2T Jw T T This filter is not implementable since its impulse response is infinite and noncausal To create a finite duration impulse response truncate it by applying a window By retaining the central section of impulse response in this truncation you obtain a linear phase FIR filter For example a length 51 filter with a lowpass cutoff frequency Wo of 0 42 rad sec is b 0 4 sinc 0 4 25 25
410. pecifying a variable or a value isthesame for all data types In the following illustration the selected variable is being imported as a signal See Importing a Signal on page 5 12 Importing a Filter on page 5 12 and I mporting a Spectrum on page 5 13 for details on customizing variables that are imported into SPTool 1 Click on a variable name in the Workspace Contents list or the File Contents list to select it If the variable is not a saved data object from SPT ool select the appropriate data type Signal Filter or Spectrum from the Import As pop up menu and type a name into the Name field beat fe If the variable is a saved data object from SPTool its name is displayed in the Name field and its type Signal Filter or Spectrum is automatically selected in the Import As pop up menu 2 Click on the arrow at the left of the Data field The selected variable is transferred to the Data field NOTE You can also type a variable name into the Data field directly Using SPTool 3 Thedefault sampling frequency is 1 To change the sampling frequency of the variable you re importing you can either a Click ona variable in the Workspace Contents list or File Contents list whose value is a sampling frequency and then click on the arrow at the left of the Sampling Frequency field The selected variable is transferred to the Sampling Frequency field or b Typea value or variable name in the Sampling
411. pectively Suppose a sequence x of N points is obtained at a sample frequency of f Then for up tothe Nyquist frequency or point n N 2 1 the relationship between the actual frequency and the index k into x out of N possible indices is f k D f IN dct Discrete cosine transform DCT df t mt x Discrete Fourier transform matrix fft2 Two dimensional fast Fourier transform fftshift Rearrange the outputs off ft andfft2 filter Filter data with a recursive IIR or nonrecursive FIR filter freqz Frequency response of digital filters ifft One dimensional inverse fast Fourier transform psd Estimate the power spectral density PSD of a signal using Welch s method 6 125 fft2 Purpose Syntax Description Algorithm See Also 6 126 Two dimensional fast F ourier transform Y fft2 X Y fft2 X m n Y fft2 X performs a two dimensional FFT producing a result Y the same size as xX If X isa vector Y has the same orientation as X Y fft2 X m n truncates or zero pads X if necessary to create an m by n array before performing the FFT Theresult Y is also m by n fft2 is part of the standard MATLAB environment fft2 x is simply PETER Md This computes the one dimensional f f t of each column of x then of each row of the result The time required to computef f t 2 x depends on the number of primefactorsin m n size x fft2 is fastest when m andn are powers of 2 fft One dim
412. plies the filter in forward and reverse directions withfiltfilt 3 decimate resamples the filtered data by selecting every r th point Diagnostics Ifr is not an integer deci mate gives the following error message Resampling rate R must be an integer If n specifies an IIR filter with order greater than 13 deci mate gives the following warning Warning IIR filters above order 13 may be unreliable 6 95 decimate See Also interp Increase sampling rate by an integer factor interpolation resample Change sampling rate by any factor spline Cubic spline interpolation see the online MATLAB Function Reference upfirdn Upsample apply an FIR filter and downsample References 1 IEEE Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 Chapter 8 6 96 deconv Purpose Syntax Description Example Algorithm See Also Deconvolution and polynomial division q r deconv b a q r deconv b a deconvolves vector a out of vector b using long division The result quotient is returned in vector q and the remainder in vector r such thatb conv g a r Ifa andb are vectors of polynomial coefficients convolving them is equivalent to polynomial multiplication and deconvolution is equivalent to polynomial division The result of dividingb bya is quotient q and remainder r deconv is part of the standard MATLAB environment The convolution ofa 1 2 3 andb
413. provides an interactive graphical environment for the design of digital IIR and FIR filters based on specifications that you enter ona magnitude plot Using the Filter Designer you can design IIR and FIR filters of various lengths and types with standard frequency band configurations highpass lowpass bandpass or bandstop filters The Filter Designer provides access to many of the IIR filter design functions discussed in Chapter 2 including thebutter chebyl cheby2 andel lip functions In addition the Filter Designer provides access tother emez firis and kaiser functions for the design of FIR filters with highpass lowpass bandpass or bandstop configurations Using the Filter Designer you can e Design IIR filters with standard band configurations using the Butterworth Chebyshev type Chebyshev type II and elliptic design options e Design FIR filters with standard band configurations using the equiri pple least squares and Kaiser window design options e Specify the filter s sampling frequency and the passband and stopband edge frequencies Specify the desired amount of ripplein the filter s passband and attenuation in the stopband e Redesign a filter by manually adjusting indicators in the magnitude plot e Use an automatically computed filter order or set a custom filter order e Overlay a spectrum on the filter s magnitude response plot When you have designed a filter to your specifications you can apply the filter
414. pssdir n lists the sequences saved with length n dpssdir nw nw lists the sequences saved with time bandwidth product nw dpssdir n nw lists the sequences saved with length n and time bandwidth product nw index dpssdir iS a structure array describing the DPSS database Pass n and nw options as for the no output case to get a filtered i ndex dpss Discrete prolate spheroidal sequences Slepian sequences dpssclear Remove discrete prolate spheroidal sequences from database dpssload Load discrete prolate spheroidal sequences from database dpsssave Save discrete prolate spheroidal sequences in database 6 107 dpssload Purpose Syntax Description See Also 6 108 Load discrete prolate spheroidal sequences from database e v dpssload n nw e v dpssload n nw loads all sequences with length n and time bandwidth product nw in the columns of e and their corresponding concentrations in vector v from the DPSS MAT file databasedpss mat dpss Discrete prolate spheroidal sequences Slepian sequences dpssclear Remove discrete prolate spheroidal sequences from database dpssdir Discrete prolate spheroidal sequences database directory dpsssave Save discrete prolate spheroidal sequences in database dpsssave Purpose Syntax Description See Also Save discrete prolate spheroidal sequences in database dpsssave nw e v status dpsssave nw e v dpsssave nw e v Saves the sequences in the co
415. pulse response plot displays the response of the current filter s toa discrete time unit height impulse at t 0 5 85 5 Interactive Tools To display only an impulse response plot for the currently selected filter s 1 Click the check box next to the Zeros and Poles option to turn off the zero pole plot 2 Click the check box next to the Impulse Response option to turn on the impulse response plot and update the display wl You can change the following display characteristics of the impulse response plot Edit the Time Response L ength field in the Filter Viewer preferences panel to set the number of samples used to display the impulse response 5 86 Using the Filter Viewer Interactive Filter Analysis Viewing Step Response The step response plot displays the response of the current filter s toa discrete time unit height step function To display only a step response plot for the currently selected filter s 1 Click the check box next to the Impulse Response option to turn off the impulse response plot 2 Click the check box next to the Step Response option to turn on the step response plot and update the display You can change the following display characteristics of the step response plot Edit the Time Response Length field in the Filter Viewer preferences panel to set the number of samples used to display the step response 5 87 5 Interactive Tools Using the Spectrum Viewer Interacti
416. quence a number of ways one straightforward way is imp 1 zeros 49 1 The impulse response of the simple filter b 1 anda 1 0 9 is h filter b a imp Thei mpz function in the toolbox simplifies this operation choosing the number of points to generate and then making a stem plot using thes t em function i mpz b a 19 r 0 919 J 0 8H 0 7H J 0 6H Ilo J 0 54 J 0 44 o J 0 3H 4 0 2H 4 0 14 0 TOR MONTELLA 0 10 20 30 40 50 60 70 80 90 The plot shows the exponential decay h n 0 9n of the single pole system 1 23 1 Signal Processing Basics Frequency Response 1 24 The Signal Processing Toolbox enables you to perform frequency domain analysis of both analog and digital filters Digital Domain f reqz uses an FF T based algorithm to calculate the z transform frequency response of a digital filter Specifically the statement h w freqz b a n returns the n point complex frequency response H a of the digital filter bO b 2 e I 4b nb Ne JO fic Hel jo na a l a 2 eJ a natle In its simplest form f r eqz accepts the filter coefficient vectorsb anda and an integer n specifying the number of points at which to calculate the frequency response f r eqz returns the complex frequency response in vector h and the actual frequency points in vector w in radians second f reqz can accept other parameters such as
417. quences of the2 nw discrete prolate spheroidal sequences calculated k must be between 0 and 2 nw e v dpss n nw k1 k2 returns thek1 th through thek 2 th sequences from the 2 nw discrete prolate spheroidal sequences calculated where 1 lt kil lt k2 lt 2 nw For all of the above forms e The Slepian sequences are calculated directly e The sequences are generated in the frequency band lt 2zW where W nw n is the half bandwidth and o is in radians e e 1 isthelengthn signal most concentrated in the frequency band lt 22W radians e 2 isthesignal orthogonal toe 1 that is most concentrated in this band e 3 is the signal orthogonal to both e 1 ande 2 that is most concentrated in this band etc e For multitaper spectral analysis typical choices for nw are 2 5 2 3 7 2 or 4 e v dpss n nw spline uses spline interpolation to computee and v from the sequences indpss mat with length closest ton dpss See Also References e v dpss sequences e v dpss e v dpss faster but less e v dpss e v dpss n nw spline Ni interpolates from existing length Ni n nw linear and n nw linear Ni Uuselinear interpolation which is much accurate than spline interpolation Iinear requiresNi gt n trace and int trace useatrailing trace argument to find out which method DPSS uses where i nt iseither spline or linear
418. r coefficients that describe the second order section bor bi 521 a 41 an bo2 bi2 bn ap a2 an SOSTE xr bot Sin b2L a L UL aL There are an uncountable number of ways to represent a filter in second order sections form Through careful pairing of the pole and zero pairs ordering of the sections in the cascade and multiplicative scaling of the sections it is possible to reduce quantization noise gain and avoid overflow in some fixed point filter implementations Thefunctionszp2sos andss2sos described later in Linear System Transformations perform pole zero pairing section scaling and section ordering Lattice Structure For a discrete Nth order all pole or all zero filter described by the polynomial coefficients a n n 1 2 N 1 there are N corresponding lattice structure coefficients k n n 1 2 N The parameters k n are also called the reflection 1 37 1 Signal Processing Basics coefficients of the filter Given these reflection coefficients you can implement a discrete filter as O zr gt y m x m k 1 k n k 1 k n g O FIR Lattice Filter y m x m IIR Lattice Filter For a general pole zero IIR filter described by polynomial coefficients a and b there are both lattice coefficients k n for the denominator a and ladder coefficients v n for the numerator b The lattice ladder filter may be implemented as k 1 k 1
419. r 2 0 0 0 c eee 2 9 Chebyshev Type ll Filter 0 0 0 0 00 20 c eee eee ee 2 10 Elliptic Filtered nga Atw pelt cota wege teehee 2 10 Bessel Filter 2 0 000 c eee eee 2 11 Direct IIR Filter Design 0 00 00 cece eee eee 2 13 Generalized Butterworth Filter Design 2 14 FIR Filter Design 0 0 cece eee eee 2 16 Linear Phase Filters 00 00 c cece eee ee 2 17 Windowing Method 0 000 cece eee 2 18 Standard Band FIR Filter Design firl 2 20 Multiband FIR Filter Design fir2 2 21 Multiband FIR Filter Design with Transition Bands 2 22 Basic Configurations 00 cee eee 2 22 The Weight Vector 00 0 2 24 Anti Symmetric Filters Hilbert Transformers 2 25 Differentiators 0 0 0 ccc eee 2 26 Constrained Least Squares FIR Filter Design 2 27 Basic Lowpass and Highpass CLS Filter Design 2 28 Multiband CLS Filter Design 0000e eee 2 29 Weighted CLS Filter Design 0 000 e eee 2 30 Arbitrary Response Filter Design 02000 e eee 2 31 Multiband Filter Design 0 cece eee eee 2 32 Filter Design with Reduced Delay 2 34 Special Topics in IIR Filter Design 2 37 Analog Prototype Design 0 cece eee eee 2 38 Frequency Transformation 000 cece eee ee 2 38 Filter Discretization
420. r Design 2 32 This capability makes cr emez a highly versatile and powerful technique for filter design This design technique may be used to produce nonlinear phase FIR filters asymmetric frequency response filters with complex coefficients or more symmetric filters with custom frequency responses The design algorithm optimizes the Chebyshev or minimax error using an extended Remez exchange algorithm for an initial estimate If this exchange method fails to obtain the optimal filter the algorithm switches to an ascent descent algorithm that takes over to finish the convergence to the optimal solution For details on the calling syntax for cr emez see the reference description in Chapter 6 Multiband Filter Design Consider a multiband filter with the following special frequency domain characteristics Band Amplitude Optimization Weighting 1 0 5 5 1 1 0 4 0 3 2 2 10 0 4 0 8 2 1 5 A linear phase multiband filter may be designed using the predefined frequency response function mul ti band as follows b cremez 38 1 0 5 0 4 0 3 0 4 0 8 multiband 5 1 2 2 2 1 1 10 5 For the specific case of a multiband filter we can use a shorthand filter design notation similar to the syntax for r e mez b cremez 38 1 0 5 0 4 0 3 0 4 0 8 5 12221 1 10 5 FIR Filter Design As with r e mez a vector of band edges is passed toc r emez This vector defines
421. r a signal subspace or a noise subspace Eigenanalysis Overview Consider a number of complex sinusoids embedded in white noise You can write the autocorrelation matrix R for this system as the sum of the signal autocorrelation matrix S and the noise autocorrelation matrix W R S W There is a close relationship between the eigenvectors of the signal autocorrelation matrix and the signal and noise subspaces The eigenvectors v of S span the same signal subspace as thesignal vectors If the system contains M complex sinusoids and the order of the autocorrelation matrix is p eigenvectors Vy 1 through vp 1 span the noise subspace of the autocorrelation matrix Frequency Estimator Functions To generate their frequency estimates eigenanalysis methods calculate functions of the vectors in the signal and noise subspaces Both the MUSIC and EV techniques choose a function that theoretically goes to infinity at one of the sinusoidal frequencies in the input signal Using digital technology the resulting estimate has sharp peaks at the frequencies of interest this means that there won t be infinity values in the vectors The MUSIC estimate is given by the formula P music f N 2 Hef ve ken E vee k p 1 k p 1 where N is the size of the eigenvectors and e f is a complex sinusoid vector H e f 1 exp j2nf exp j2nf 2 exp j2nf 4 exp j2nf n 1 v represents the eigenvectors of the input signal s correlatio
422. r design and power spectrum estimation the choice of a windowing function can play an important role in determining the quality of overall results The main role of the window is to damp out the effects of the Gibbs phenomenon that results from truncation of an infinite series The toolbox window functions are Window Function Bartlett window bartlett Blackman window blackman Rectangular window boxcar Chebyshev window chebwin Hamming window hammi ng Hanning window hanni ng Kaiser window kaiser Triangular window triang Basic Shapes The basic window is the rectangular window a vector of ones of the appropriate length A rectangular window of length 50 is n 50 w boxcar n This toolbox stores windows in column vectors by convention so an equivalent expression is w ones 50 1 The Bartlett or triangular window is the convolution of two rectangular windows The functions bart ett andtriang compute similar triangular windows with three important differences Thebart ett function always W indows returns a window with two zeros on the ends of the sequence sothat for n odd the center section of bart ett n 2 is equivalent tot ri ang n bartlett 7 ans 0 3333 6667 0000 6667 3333 0 oorno o triang 5 ans 3333 6667 0000 6667 3333 oorno o Forn even bartl ett is still the convolution of two rectangular sequences Thereis no standard definition for the tr
423. r prototype cheb2ap Chebyshev type II analog lowpass filter prototype ellip Elliptic Cauer filter design 1 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 Chapter 7 ellipord Purpose Syntax Description Elliptic filter order selection n Wn ell i pord Wp Ws Rp Rs n Wn ellipord Wp Ws Rp Rs s ell i pord selects the minimum order digital or analog elliptic filter required to meet a set of lowpass filter design specifications Wp Passband corner frequency Wp the cutoff frequency has a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Ws Stopband corner frequency Ws is in the same units as Wp it has a value between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency Rp Passband ripple in decibels This value is the maximum permissible passband loss in decibels The passband is 0 lt w lt Wp Rs Stopband attenuation in decibels This value is the number of decibels the stopband is down from the passband The stopband isWs lt w lt 1 Digital Domain n Wn ellipord Wp Ws Rp Rs returns the order n of the lowest order elliptic filter that loses no morethan Rp dB in the passband and has at least Rs dB of attenuation in the stopband The passband runs from 0 toWp and the stopband extends from Ws to 1 the Nyquist frequency el I i pord also returns Wn the c
424. r section conversion Zero pole gain to state space conversion Zero pole gain to transfer function conversion IIR Filter Design Classical and Direct bessel f butter chebyl cheby2 el lip maxflat yul ewal k Bessel analog filter design Butterworth analog and digital filter design Chebyshev type filter design passband ripple Chebyshev type II filter design stopband ripple Elliptic Cauer filter design Generalized digital Butterworth filter design Recursive digital filter design 6 4 IIR Filter Order Selection buttord cheblord cheb2ord ellipord Butterworth filter order selection Chebyshev type filter order selection Chebyshev type II filter order selection Elliptic filter order selection FIR Filter Design cremez f fj fj rl ir2 ircls irclsl rls irrcos ntfilt kaiserord remez remezord Complex and nonlinear phase equiripple FIR filter design Window based finite impulse response filter design standard response Window based finite impulse response filter design arbitrary response Constrained least square FIR filter design for multiband filters Constrained least square filter design for lowpass and highpass linear phase FIR filters Least square linear phase FIR filter design Raised cosine FIR filter design Interpolation FIR filter design Estimate parameters for an FIR filter design with Kaiser wi
425. ransition regions implicitly rather than explicitly The key feature of the CLS method is that it enables you to define upper and lower thresholds that contain the maximum allowable ripple in the magnitude response Given this constraint the technique applies the least square error minimization technique over the frequency range of the filter s response instead of over specific bands The error minimization includes any areas of discontinuity in the ideal brick wall response An additional benefit is that 2 27 2 Filter Design 2 28 the technique enables you to specify arbitrarily small peaks resulting from Gibbs phenomena There are two toolbox functions that implement this design technique Description Function Constrained least square multiband FIR filter design fircls Constrained least square filter design for lowpass and fircis1 highpass linear phase filters For details on the calling syntax for these functions see their reference descriptions in Chapter 6 Basic Lowpass and Highpass CLS Filter Design The most basic of the CLS design functions f i rci s1 uses this technique to design lowpass and highpass FIR filters As an example consider designing a filter with order 61 impulse response and cutoff frequency of 0 3 normalized Further define the upper and lower bounds that constrain the design process as e Maximum passband deviation from 1 passband ripple of 0 02 e Maximum stopband dev
426. rder is checked automatic order selection The stopband edge frequency parameters listed Fs Fs1 Fs2 arethe actual edge frequencies for the design rather than the desired frequencies entered in the Specifications panel Low pass Highpass Bandpass Bandstop Equiripple FIR oe Rs Wp oe Rs Wp Order Rp Rs Wp Ws Order Rp Rs Wp Ws Least Squares FIR Kaiser Window FIR Butterworth IIR Chebyshev Type IIR Chebyshev Type II IIR Elliptic IIR Order cannot be automatically computed Order Fc Beta Order Fc Beta Order Fc1 Fc2 Beta Rp Order Fcl Fc2 Beta Rp Rp Rs Rp Rs Rs Rs Order Rp F3db Order Rp F3db Order Rp F3db1 F3db2 Order Rp F3db 1 F3db2 Order Fs Order Fs Order Fs1 Fs2 Order Fs1 Fs2 Order Fs Order Fs Order Fs1 Fs2 Order Fs1 Fs2 Order Fs Order Fs Order Fs1 Fs2 Order Fs1 Fs2 Measurement Parameters Manual Order Selection The next table shows the Sipeilicahone Miira Oder parameter sets that appear in the Measurements panel when Minimum Order is not selected The measurements that can be interactively changed by dragging the red measurement lines on the response plot are shown in italics Low pass Highpass Bandpass Bandstop Equiripple FIR Rp Rs Rp Rs Rp Rs Rp Rs Least Squares FIR Rp Rs Rp Rs Rp Rs Rp Rs Kaiser Window FIR Fp Fs Rp Rs Fp Fs Rp Rs Fpl Fp2 Fsi1 Fs2 Rp Rs_ Fpl Fp2 Fsl Fs2 Rp Rs Butterw orth IIR Fp Fs Rp Rs Fp Fs Rp Rs Fpl
427. re made about the optimality of the resulting filter 2 13 2 Filter Design Design a multiband filter with yul ewal k and plot the desired and actual frequency response m 0 0 1 1 0 0 f 0 0 1 0 2 0 3 0 4 0 5 b a yulewalk 10 f m h w freqgz b a 128 plot f m w pi abs h 1 1 0 0 6 7 0 8 1 0 6 0 Generalized Butterworth Filter Design The toolbox function maxf at enables you to design generalized Butterworth filters that is Butterworth filters with differing numbers of zeros and poles This is desirable in some implementations where poles are more expensive computationally than zeros maxfl at isjustlikethebutter function except that it you can specify two orders one for the numerator and one for the denominator instead of just one These filters are maximally flat This means that the resulting filter is optimal for any numerator and denominator orders with the maximum number of derivatives at 0 and the Nyquist frequency w n both set to 0 IIR Filter Design For example when the two orders arethesame ma xf at isthesameasbutter b a maxflat 3 3 0 25 b 0 0317 0 0951 0 0951 0 0317 1 0000 1 4590 0 9104 0 1978 b a butter 3 0 25 0 0317 0 0951 0 0951 0 0317 1 0000 1 4590 0 9104 0 1978 However ma xf I at iS more versatile because you can design a filter with more zeros than poles b a maxflat 3 1 0 25 b 0 0950 0 2849 0 2849 0 0950 1
428. reated or when you have changed one or more parameters in the Spectrum Viewer The updated spectrum is displayed in the Spectrum Viewer See Using the Spectrum Viewer Interactive PSD Analysis on page 5 88 for a full description of Spectrum Viewer parameters and displays Viewing a Spectrum Use the View button in the Spectrum panel to activate the Spectrum Viewer and display one or more selected spectra Select one or more spectra from the Spectra list and click View in the spectrum panel The Spectrum Viewer displays the selected spectrum or spectra Updating a Spectrum Use the Update button to update the selected spectrum so that it reflects the data in the currently selected signal 1 Select one signal from the Signals list and one spectrum from the Spectra list and click Update in the Spectra panel The spectral data from the current spectrum is removed from the Spectrum Viewer The Spectrum Viewer is activated No spectrum is displayed yet 2 Press Apply in the Spectrum Viewer to compute the spectrum and complete the update The spectrum is regenerated with the same parameters but using the data inthe currently selected signal This featureis useful when you have altered a signal by filtering it for example and want to update the existing spectrum to reflect the change Using SPTool Customizing Preferences Use Preferences from the File menu to customize displays and certain parameters for SPTool and its
429. rediction coefficients M magnitude of F ourier transform of sequence 1 44 of frequency response 1 26 viewing in Filter Viewer 5 80 of transfer function estimate 3 15 vector 2 24 6 141 6 144 6 333 Magnitude Axis Scaling pop up menu in Preferenc es dialog box 5 25 5 26 Magnitude check box F ilter Viewer 5 77 magnitude plot in Filter Designer 5 62 5 68 magnitude response 5 18 magnitude response plot 5 68 5 77 5 80 in Filter Designer 5 59 Magnitude Scale pop up menu Spectrum Viewer 5 90 magnitude scale in Spectrum Viewer 5 90 manufacturing 4 10 Marker Size edit box in Preferences dialog box 5 22 match frequency for prewarping 6 20 MAT file dpss mat 3 19 importing 1 13 importing into SPT ool 5 5 5 7 loading into SPT ool 5 9 MAT file format converting to 1 13 matrices convolution 1 39 6 72 correlation coefficient 6 74 covariance 6 75 data 1 4 1 7 discrete F ourier transform 6 102 for second order sections form 1 37 inverse discrete F ourier transform 6 102 matrix form See state space form maxflat 2 5 2 14 6 4 6 215 Index maxima local 5 36 maximally flat 2 14 measurement lines 5 62 measurements in Filter Viewer 5 37 in Signal Browser 5 37 in Spectrum Viewer 5 37 5 92 saving in Filter Viewer 5 36 saving in Signal Browser 5 36 saving in Spectrum Viewer 5 36 medfilt1 4 27 6 9 6 217 median filter 4 27 6 217 message signal 4 28 6 218 Method pop up menu Spectrum Viewer 5 94 ME X file 1 13 M files
430. representing in MATLAB 1 33 zeros and poles 5 18 in transfer function 1 33 Zeros and Poles check box Filter Viewer 5 77 zoom controls in Filter Designer 5 30 in Filter Viewer 5 30 in Signal Browser 5 30 in Spectrum Viewer 5 30 in SPTool 5 30 Zoom In X button 5 31 Zoom In Y button 5 31 Zoom Out X button 5 31 Zoom Out Y button 5 31 zoom persistence 5 31 changing 5 31 in Filter Designer 5 28 in Filter Viewer 5 27 5 78 in Signal Browser 5 24 5 44 in Spectrum Viewer 5 25 zooming in Filter Designer 5 67 in Filter Viewer 5 78 in Signal Browser 5 44 in Spectrum Viewer 5 93 one time 5 31 persistent 5 31 zp2sos 1 42 6 4 6 336 zp2ss 1 42 6 4 6 339 zp2tf 6 340 zp2tf 1 42 6 309 6 340 zpl ane 1 30 6 3 6 341 z transform 1 15 1 32 chirp z transform CZT 4 33 6 89 discrete F ourier transform 1 43 1 27 Index 1 28
431. requency of 0 48 usinga Chebyshev window with 30 dB of ripple b firl 34 0 48 high chebwi n 35 30 xfilt filter b 1 x Diagnostics If n is odd and you specify a bandstop or highpass filter f i r 1 gives the following warning message For highpass and bandstop filters N must be even Order is being increased by 1 6 139 firl See Also References 6 140 filter fircls firclsl firls freqz kaiserord remez Filter data with a recursive IIR or nonrecursive FIR filter Window based finite impulse response filter design arbitrary response Constrained least square FIR filter design for multiband filters Constrained least square filter design for lowpass and highpass linear phase FIR filters Least square linear phase FIR filter design Frequency response of digital filters Estimate parameters for f i r1 with Kaiser window Parks McClellan optimal FIR filter design 1 EEE Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 Algorithm 5 2 fir2 Purpose Syntax Description Window based finite impulse response filter design arbitrary response fir2 n f fir2 n f fir2 n f f f f m wi ndow npt npt wi ndow npt lap npt lap wi ndow fir2 n fir2 n fir2 n oe o o or oe B BBBB fi r2 designs windowed digital FIR filters with arbitrarily shaped frequency response For standard lowpass band
432. response data or input and output sequences these functions find the coefficients of a linear system that models the system One important application of the parametric modeling functions is in the design of filters that have a prescribed time or frequency response These functions provide a data oriented alternative to the IIR and FIR filter design functions discussed in Chapter 2 Here is a summary of the parametric modeling functions in this toolbox Note that the System Identification Toolbox provides a more extensive collection of parametric modeling functions Domain Functions Description Time Ipc Linear Predictive Coding Generate all pole recursive filter whose levinson impulse response matches a given sequence prony Generate IIR filter whose impulse response matches a given sequence st mcb Find IIR filter whose output given a specified input sequence matches a given output sequence Frequency invfreqz Generate digital or analog filter coefficients given complex invfreqs frequency response data pburg Generate IIR filter coefficients that model an input data sequence using the Levinson Durbin algorithm see Chapter 3 Parametric M odeling Domain Functions Description pyulear Generate IIR filter coefficients that model an input data sequence using an estimate of the autocorrelation function see Chapter 3 yul ewal k Generate IIR filter that matches piecewise linear magnitude response by solvin
433. response is shown below Desired amplitude response a 1 0 Normalized 0 0 cocesmmmammmmbsooed o neveed__ge frequency f 0 0 01 02 03 04 05 06 0 7 0 8 0 9 1 0 Nyquist evceee Don t care transition regions remez n f a w uses the weights in vector w to weight the fit in each frequency band The length of w is half the length off anda sothereis exactly one weight per band 6 256 remez b remez n f a ftype and remez n f a w ftype specify a filter type wheref type is hil bert for linear phase filters with odd symmetry type II and type IV The output coefficients in b obey the relation b k b n 2 k k 1 n 1 This class of filters includes the Hilbert transformer which has a desired amplitude of 1 across the entire band For example h remez 30 0 1 0 9 1 1 hilbert designs an approximate FIR Hilbert transformer of length 31 differentiator for typelll and IV filters using a special weighting technique For nonzero amplitude bands it weights the error by a factor of 1 f so that the error at low frequencies is much smaller than at high frequencies F or FIR differentiators which have an amplitude characteristic proportional to frequency these filters minimize the maximum relative error the maximum of the ratio of the error to the desired amplitude remez lgrid Uusestheinteger grid to control the density of the frequency grid which has roughly grid n 2 bw
434. ription Algorithm See Also References Real cepstrum and minimum phase reconstruction y rceps x y ym rceps x Thereal cepstrum is the inverse F ourier transform of the real logarithm of the magnitude of the Fourier transform of a sequence rceps x returns the real cepstrum of the real sequencex The real cepstrum is a real valued function y ym rceps x returns both the real cepstrumy anda minimum phase reconstructed version ym of the input sequence rceps isan M file implementation of algorithm 7 2 in 2 that is y real ifft log abs fft x Appropriate windowing in the cepstral domain forms the reconstructed minimum phase signal w 1 2 ones n 2 1 1 ones 1 rem n 2 1 zeros n 2 1 1 ym real ifft exp fft w y cceps Complex cepstral analysis fft One dimensional fast Fourier transform hilbert Hilbert transform icceps Inverse complex cepstrum unwrap Unwrap phase angles 1 Oppenheim A V and R W Schafer Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 2 EEE Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 6 253 rectpuls Purpose Syntax Description See Also 6 254 Sampled aperiodic rectangle generator y rectpuls t y rectpuls t w y rectpuls t returns a continuous aperiodic unity height rectangular pulse at the sample times indicated in array t centered aboutt
435. ristics of a filter that you ve imported or designed including its magnitude and phase 5 2 SPTool An Interactive Signal Processing Environment responses its group delay its zero pole plot and its impulse and step responses e The Spectrum Viewer which enables you to interactively create view and modify spectra and to perform graphical analysis of frequency domain data using a variety of common methods of spectral estimation 5 3 5 Interactive Tools Using SPTool 5 4 SPTool isthedata management tool for the interactive GUI environment of the Signal Processing Toolbox Using SPTool you can e Load a saved session e Import a signal filter or spectrum e Duplicate or clear a signal filter or spectrum e Change the name of a signal filter or spectrum e Change the sampling frequency of a signal or filter e Activate the Signal Browser Filter Viewer Filter Designer or Spectrum Viewer e Save a session e Use the Window menu to change to any open MATLAB Figure window Opening SPTool Open SPTool from the MATLAB command window by typing sptool and pressing Enter Return on Macintosh Quick Start Once SPT ool is open you can import data from the workspace or a file You can then view it in the Signal Browser or generate its default spectrum in the Spectrum Viewer Toget started right away work through the following example Then continue through this chapter to learn the details of using SPTool and i
436. rm STFT has numerous applications in speech sonar and radar processing The spectrogram of a sequence is the magnitude of the time dependent F ourier transform versus time To display the spectrogram of a linear FM signal Fs 10000 t 0 1 Fs 2 x vco sawtooth 2 pi t 75 0 1 0 4 Fs Fs specgram x 512 Fs kaiser 256 5 220 5000 m 7 EHE 7 a Ean z 4500 a 4000 3500 N wo a fo fo fo oO fo Frequency 2000 1500 1000 0 0 2 0 4 0 6 0 8 1 12 1 4 1 6 1 8 Time Note that the spectrogram display is an image not a plot 4 26 M edian Filtering Median Filtering The function medf i t1 implements one dimensional median filtering a nonlinear technique that applies a sliding window to a sequence The median filter replaces the center value in the window with the median value of all the points within the window 4 In computing this median me df i t 1 assumes zeros beyond the input points When the number of elements n in the window is even medf i I t1 sorts the numbers then takes the average of the n 1 2 amp n 1 2 1 elements Two simple examples with fourth and third order median filters are medfiltl 4 3 5 2 8 9 1 4 ans 1 500 3 500 3 500 4 000 6 500 5 000 4 500 medfilti 4 3 5 2 8 9 1 3 ans 3 4 3 5 8 8 1 See the mage Processing T ool box User s Guide for information on two dimensional median filtering 4 27 4 Special Topics
437. rol is selected See Making Signal Measurements on page 5 37 for details on the four kinds of measurements you can make and the parameters for each one Rulers Rulers Panel and Edit Boxes The Rulers panel changes depending on which ruler E control is selected Vertical Horizontal Track or Slope It shows the Vertical _ Horizontal parameters for the selected ruler control Depending on which ruler control is Oss e Se a selected the following fields are displayed x1 y1 x2 y2 dx dy m The Track Slope picture on the left shows the Rulers panel when Slope is selected x1 0 091803721 y1 1 3809065 When you click on a ruler control button rulers are displayed superimposed on the signal s in the main axes display area The rulers are either vertical for 2f 0 10056619 Vertical Track and Slope or horizontal for Horizontal For Track and y2 0 20907761 Slope ruler markers are also displayed The rulers and ruler markers are dx 0 0087624697 associated with the currently selected signal The following picture shows the dy 1 1718289 rulers and ruler markers that are displayed when Slope is selected m 133 73272 mtlb mtlb1 Peaks ye Save Rulers 0 075 0 08 008 009 0095 O1 O105 O11 Time To position a ruler you can click and drag on it When you drag a ruler the parameters in the Rulers panel change to reflect the measurements on the selected signal 5 35 5 Interactive Tools
438. roup dday is a measure of the average delay of a filter as a function of frequency To display only a group delay plot for the currently selected filter s 1 Click the check box next to the Phase option to turn off the phase plot 2 Click the check box next to the Group Delay option to turn on the group delay plot and update the display pa raup Delay By default this plot uses the default scaling and range for the frequency axis You can change the following display characteristics of the group delay plot e Use the Scale pop up menu to choose between linear and log scaling of the x axis e Use the Range pop up menu to choose between the following ranges for the x axis 0 Fs 2 0 Fs or Fs 2 F s 2 where Fs represents the highest sampling frequency of the currently selected filters 5 84 Using the Filter Viewer Interactive Filter Analysis Viewing a Zero Pole Plot Thezero poleplot displays the poles and zeros of thetransfer function and their proximity tothe unit circle An x represents a pole of the transfer function ao represents a zero of the transfer function To display only a zero pole plot for the currently selected filter s 1 Click the check box next to the Group Delay option to turn off the group delay plot 2 Click the check box next to the Zeros and Poles option to turn on the zero pole plot and update the display Ll bt df pE Al ai n EEEE Viewing Impulse Response The im
439. rs butt ord returns Wn asa two element row vector for input tobutter If filter specifications call for a bandpass or bandstop filter with unequal ripple in each of thepassbands or stopbands design the filter as separate lowpass and highpass sections and cascade the two filters together buttord Examples Analog Domain n Wn buttord Wp Ws Rp Rs s finds the minimum order n and cutoff frequencies Wn for an analog filter In this case the frequenciesin Wp and Ws are in radians per second and may be greater than 1 Usebuttord for highpass bandpass and bandstop filters as described under Digital Domain For data sampled at 1000 Hz design a lowpass filter with less than 3 dB of attenuation from 0 to 100 Hz and attenuation at least 15 dB from 150 Hz to the Nyquist frequency Plot the filter s frequency response Wp 100 500 Ws 150 500 n Wn buttord Wp Ws 3 15 n Wn 0 2042 b a butter n Wn freqz b a 512 1000 n 4 Butterworth Lowpass Filter Magnitude Response dB L ii L L L i L 3 i 0 50 100 150 200 250 300 350 400 450 500 Frequency Hertz 0 r Phase degrees i D k o F i L L 1 L L L L 50 100 150 200 250 300 350 400 450 500 Frequency Hertz 6 35 buttord Next design a bandpass filter with passband of 100 Hz to 200 Hz less than 3 dB of attenuation at the passband corners and attenuation down 30 dB by 50 Hz out on both
440. rs panel for each of the PSD computation methods F or detailed definitions and values for each parameter use context sensitive help see Help Button on page 5 91 Using the Spectrum Viewer Interactive PSD Analysis Burg For the Burg method you can specify the following parameters e Order Typein a value Nfft Typein a value FFT For the FFT method you can specify the following parameter Nfft Typein a value M For the MTM method you can specify the following parameters e NW Typein a value e Nfft Typein a value Weights Select one of the following from the pop up menu adapt unity eigen Conf Int Check to compute a confidence interval and type in a value see Setting Confidence Intervals on page 5 98 5 95 5 Interactive Tools Music For the MUSIC method you can specify the following parameters e Signal Dim 5 Type in a value lt lt Threshold ceel Type in a value e Nfft Type in a value Bed e Nwind Cee 5 Type in a value et e Window Select a window from the pop up menu e Overlap Type in a value e Corr Matrix Check if selected signal is a correlation matrix e Eigenvector Weights Check to select eigenvector weights 5 96 Using the Spectrum Viewer Interactive PSD Analysis Welch For Welch s method you can specify the following parameters NFFT Seer Typein a value Nwind ma Type in a value S Wind
441. rth filters Butterworth filters are characterized by a magnitude response that is maximally flat in the passband and monotonic overall Butterworth filters sacrifice rolloff steeoness 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 b a butter n Wn designs an ordern lowpass digital Butterworth filter with cutoff frequency Wn It returns the filter coefficients in lengthn 1 row vectors b anda with coefficients in descending powers of z _ Biz _ BO 2 z 1 b Nz A z 14 a 2 z a n z H z Cutoff frequency is that frequency where the magnitude response of the filter issqrt 1 2 Forbutter thecutoff frequency Wn must bea number between 0 and 1 where 1 corresponds to half the sampling frequency the N yquist frequency If Wn isatwo element vector Wn wl w2 butter returns an order 2 n digital bandpass filter with passband wl lt lt w2 6 29 butter 6 30 b a butter n Wn ftype designsa highpass or bandstop filter where ftype is e high for a highpass digital filter with cutoff frequency Wn e stop for an order 2 n bandstop digital filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 With different numbers of output arguments but t er directly obtains other realizat
442. s Filtering with the filter Function It is simpleto work back toa difference equation from the z transform relation shown earlier Assume that a 1 1 Move the denominator to the left hand side and take the inverse z transform y n a 2 y n 1 a na I y n na b x n B 2 x n 1 b nb I x n nb 1 15 1 Signal Processing Basics In terms of current and past inputs and past outputs y n is y n bd x n b 2 x n 1 b nb 1 x n nb a 2 y n 1 a na I y n na 1 16 This is the standard time domain representation of a digital filter computed starting with y 1 and assuming Zero initial conditions This representation s progression is y0 bx y 2 b 1 x 2 b 2 x 1 a 2 yA y 3 DU x 3 b 2 x 2 b 3 x D a 2 2 a3 y 1 A filter in this form is easy to implement with thefi ter function For example a simple single pole filter lowpass is b a a numerator 1 0 9 denomi nator where the vectors b anda represent the coefficients of a filter in transfer function form To apply this filter to your data y filter b a x filter gives you as many output samples as there are input samples that is the length of y is the same as the length of x If the first element of a is not 1 filter divides the coefficients by a 1 prior to implementing the difference equation filter Function Implementation and Initial C
443. s 1 0 devs 0 05 0 01 n Wn beta ftype kaiserord fcuts mags devs fsamp hh firl n Wn ftype kaiser n 1 beta noscale freqz hh a Oo Oo Magnitude Response dB a oO 100 1 x L L L mG 0 2 0 4 0 6 0 8 1 Normalized frequency Nyquist 1 0 T 3 5 500 F J o 2 o 2 1000 4 Po D 1500 a J 0 0 2 0 4 0 6 0 8 1 Normalized frequency Nyquist 1 6 196 kaiserord Design an odd length bandpass filter note that odd length means even order so the input tof i r 1 must bean even integer fsamp 8000 fcuts 1000 1300 2410 mags 0 1 0 devs 0 01 0 05 0 01 n Wn beta ftype kaiserord fcuts mags devs fsamp n n remn 2 hh firl n Wn ftype kaiser n 1l beta noscale H f fregz hh 1 1024 fsamp plot f abs H grid on 1 4 0 67 0 47 0 2 0 L L L 0 500 1000 1500 2000 2500 3000 3500 4000 Design a lowpass filter with a passband cutoff of 1500 Hz a stopband cutoff of 2000 Hz passband ripple of 0 01 stopband ripple of 0 1 and a sampling frequency of 8000 Hz n Wn beta ftype kaiserord 1500 2000 1 0 0 01 0 1 8000 b firl n Wn ftype kaiser n l beta noscale This is equivalent to c kaiserord 1500 2000 1 0 0 01 0 1 8000 cell b firl c 6 197 kaiserord Remarks Diagnostics See Also References 6 198 Be careful to distingui
444. s 0 4000 1 0000 1 0000 0 B 1 0 C 2 0000 3 0000 1 6000 0 D 0 1 There is disagreement in the literature on naming conventions for the canonical forms It is easy however to generate similarity transformations that convert to other forms F or example T fliplr eye n A T AT Algorithm tf2ss writes the output in controller canonical form by inspection See Also ss2tf State space to transfer function conversion ss2zp State space to zero pole gain conversion tf2zp Transfer function to zero pole gain conversion zp2ss Zero pole gain to state space conversion zp2tf Zero pole gain to transfer function conversion 6 308 tf2zp Purpose Syntax Description Transfer function to zero pole gain conversion z p k tf2zp num den tf 2zp finds the zeros poles and gains of a system in polynomial transfer function form z p k tf2zp num den finds the single input multi output SIMO factored transfer function form Zs k s Z 1 s Z 2 s Z m p s s p s p 2 8 p given a SIMO system in polynomial transfer function form H s nn 1 nd 1 num nn 1 s num nn den nd 1 s den nd num s _ num 1 s den s den 1 s Vector den specifies the coefficients of the denominator in descending powers of s Matrix num indicates the numerator coefficients with as many rows as there are outputs The zero locations are returned in the
445. s Color is specified as a string eg r or RGB triple eg 1 0 0 Type in a new value to change the ruler color Ruler Marker Specifies the marker used in the track and slope rulers Click in the pop up menu and drag to select a different marker Marker Size Specifies the size of the ruler marker in points This can be any positive value Type in a new value to change the marker size Initial Type Specifies the type of ruler horizontal vertical track or slope that is selected when you first open the Signal Browser Spectrum Viewer or Filter Viewer Click in the pop up menu and drag to select a different ruler type 5 22 Using SPTool Color Settings The Colors preferences apply to signals displayed in the Signal Browser Spectrum Viewer and Filter Viewer iira Skea Deda ee ae er ee Color Order Specifies the color order to cycle through for data plotted in the Signal Browser Spectrum Viewer and Filter Viewer The default is the axis color order Type in anew valueor value string to change the color order Color is specified as a string e g r or RGB triple eg 1 0 0 an n by 3 matrix of n colors or an n by 1 cell array of such objects Line Style Order Specifies the line styles to cycle through for data plotted in the Signal Browser Spectrum Viewer and Filter Viewer The default is the axis line style order Type in a new string value e g or an array of strings eg
446. s sawtooth sin sinc square tripuls Cosine of vector matrix elements see the online MATLAB Function Reference Dirichlet or periodic sinc function Gaussian modulated sinusoidal pulse generator Pulse train generator Sampled aperiodic rectangle generator Sawtooth or triangle wave generator Sine of vector matrix elements See the online MATLAB Function Reference Sinc function Square wave generator Sampled aperiodic triangle generator cohere Purpose Syntax Description Estimate magnitude squared coherence function between two signals Cxy cohere x y Cxy cohere x y nfft Cxy f cohere x y nfft Fs Cxy cohere x y nfft Fs window Cxy cohere x y nfft Fs window noverl ap Cxy cohere x y dflag cohere x y Cxy cohere x y finds the magnitude squared coherence between length n signal vectorsx andy Thecoherenceis a function of the power spectra of x and y and the cross spectrum of x andy 2 Pry Pf cyt fel nD Px Py Pf x andy must bethe same length Cxy cohere x y usesthefollowing default values e nfft min 256 length x e Fs 2 e window hanning nfft e noverlap 0 nfft specifies the FFT length that cohere uses This value determines the frequencies at which the coherenceis estimated Fs isa scalar that specifies the sampling frequency wi ndow specifies a windowing function and the number of samples cohere uses in its sectioning of thex a
447. s Chebyshev type filter with a value of 3 dB for passband ripple z p k cheblap 5 3 2 39 2 Filter Design 2 40 z p andk contain the poles zeros and gain of a lowpass analog filter with cutoff frequency Q equal to 1 rad sec Use the p2bp function totransform this lowpass prototype to a bandpass analog filter with band edges W1 7 5 and Wo n First convert the filter to state space form so the p2bp function can accept it A B C D zp2ss z p k Convert to state space form Now find the bandwidth and center frequency and call p2bp ul 0 1 2 pi u2 0 5 2 pi in radians per second Bw u2 ul Wo sqrt ul u2 Bt Ct Dt p2bp A B C D Wo Bw Finally calculate the frequency response and plot its magnitude b a ss2tf At Bt Ct Dt Convert to TF form w linspace 01 1 500 2 pi Generate frequency vector h freqs b a w Compute frequency response semilogy w 2 pi abs h grid Plot log magnitude vs freq L pi 5 pi Frequency rad sec Special Topics in IIR Filter Design Filter Discretization The third step in the analog prototyping techniqueis the transformation of the filter to the discrete time domain The toolbox provides two methods for this theimpulseinvariant and bilinear transformations The filter design functions butter chebyl cheby2 andell ip usethe bilinear transformation for discretization in this step Analog t
448. s Fpl Fp2 Fs1 Fs2 Wp Ws Fpl Fp2 Fs1 Fs2 Wp Ws Least Squares FIR Fp Fs Wp Ws Fp Fs Wp Ws Fpl Fp2 Fs1 Fs2 Wp Ws_ Fpl Fp2 Fs1 Fs2 Wp Ws Kaiser Window FIR Fc Beta Fc Beta Fcl Fc2 Beta Fcl Fc2 Beta Butterw orth IIR F3db F3db F 3db 1 F 3db 2 F 3db 1 F 3db 2 Chebyshev Type IIR Fp Rp Fp Rp Fpl Fp2 Rp Fpl Fp2 Rp Chebyshev Type II IIR Fs Rs Fs Rs Fs1 Fs2 Rs Fs1 Fs2 Rs Elliptic IIR Fp Rp Rs Fp Rp Rs Fpl Fp2 Rp Rs Fpl Fp2 Rp Rs In general follow these steps to design a new filter using the Specifications panel parameters 1 Click and drag to select an appropriate filter Equipe W design from the Algorithm pop up menu Eourools FA Least Squares FIR 2 Click and drag to select the band configuration Kaiser Window FIR lowpass MS Butterworth IIA from the Type pop up menu Chebyshev Type 1 IIR Chebyshev Type 2 IIR 3 Typein the Specifications panel s editable fields Elliptic lf to change the values for band edge frequencies ripple attenuation etc lo wpa ss 4 Press Enter Return on Macintosh after typing in an editable text box to enter the value If Auto Design is not checked press the Apply button below the Specifications panel to update the magnitude plot 5 Tospecify a filter order click Minimize Order to deselect the check box and disable automatic filter order selection Then type a value for the Order parameter If Auto Design is not checked press Apply Edit a new filter or an e
449. s let you search for plug ins when SPTool is started up Playin D Teghii Pagers ist sara Search for Plug Ins at start up Enables checked or disables unchecked searching for installed plug ins A plug in is an extension to SPT ool Plug ins include customized add on panels and new buttons in the panels in SPTool new spectral methods in the Spectrum Viewer and new SPTool preferences You can also plug one or more toolboxes into SPT ool You only need to use this setting when you have installed extensions or have other toolboxes plugged into SPTool To use SPTool with extensions check Search for Plug ins at start up close SPTool and restart it Saving and Discarding Changes to Preferences Settings The buttons at the bottom of the Preferences panels let you save or discard any changes you have made or return to the default settings l al Help Factors Jeary Fram Paral Cancel LJ Factory Settings Restores the preferences in the current panel to their original settings that is the settings at the time the Signal Processing Toolbox was first installed 5 29 5 Interactive Tools 5 30 Revert Panel Cancels changes in the current panel only Settings in the current panel revert to the previous settings Cancel Cancels changes in all preferences categories and closes the Preferences window Settings in all panels revert to their previous state OK Applies changes in all preferences panels and
450. s obtained as set forth in subparagraph a of the Rights in Commercial Computer Software or Commercial Software Documentation Clause at DFARS 227 7202 3 therefore the rights set forth herein shall apply and b For any other unit or agency NOTICE Notwithstanding any other lease or license agreement that may pertain to or accompany the delivery of the computer software and accompanying documentation the rights of the Government regarding its use reproduction and disclo sure are as set forth in Clause 52 227 19 c 2 of the FAR MATLAB Simulink Handle Graphics and Real Time Workshop are registered trademarks and Stateflow and Target Language Compiler are trademarks of The MathWorks Inc Other product or brand names are trademarks or registered trademarks of their respective holders Printing History December 1996 First printing New for MATLAB 5 0 J anuary 1998 Second printing Revised for MATLAB 5 2 Before You Begin What Is the Signal Processing Toolbox xii How to Use This Manual xiii Installation 00 nena xv Typographical Conventions 5 xvi Technical Notations 00 00 c cece ee xvii Signal Processing Basics 1 Signal Processing Toolbox Central Features 1 2 Filtering and FFTS cece eee eee eee 1 2 Signals and Systems 0 006 1 2 Key Areas Filter Design and Spectral Analysis
451. s original value If the filter is stable n is chosen to be the point at which the term due to the largest amplitude pole is 5 10 5 of its original amplitude If the filter is oscillatory poles on the unit circle only i mpz computes five periods of the slowest oscillation If the filter has both oscillatory and damped terms n is chosen to equal five periods of the slowest oscillation or the point at which the term due to the impz largest nonunity amplitude pole is 5 10 5 of its original amplitude whichever is greater i mpz also allows for delay in the numerator polynomial which it adds to the resultingn See Also impulse Unit impulse response see Control System Tool box User s Guide stem Plot discrete sequence data see the online MATLAB Function Reference 6 181 interp Purpose Increase sampling rate by an integer factor interpolation Syntax y interp x r y interp x r al pha y b interp x r al pha Description Interpolation increases the original sampling rate for a sequence to a higher rate i nt er p performs lowpass interpolation by inserting Zeros into the original sequence and then applying a special lowpass filter y interp x r increases the sampling rate of x by a factor of r The interpolated vector y isr times longer than the original input x y interp x r 1 alpha specifies filter length and al pha cut off frequency The default value for is 4 and the
452. s preserving the wave shape of filtered signals in the passband Digital Bessel filters do not retain this quality andbessel f therefore does not support the design of digital Bessel filters b a besself n Wn designs an order n lowpass analog filter with cutoff frequency Wn It returns the filter coefficients in the length n 1 row vectors b anda with coefficients in descending powers of s B s _ b I s b 2 s b n 1 ACS s a a n 41 Cutoff frequency is the frequency at which the magnitude response of the filter begins to decrease significantly For bessel f the cutoff frequency Wn must be greater than 0 The magnitude response of a Bessel filter designed by bessel f is always less than sqrt 1 2 at the cutoff frequency and it decreases as the order n increases If Wn is atwo element vector Wn wl w2 withwl lt w2 besself n Wn returns an order 2 n bandpass analog filter with passband w1 lt lt w2 b a besself n Wn ftype designs a highpass or bandstop filter wheref type is e high for a highpass analog filter with cutoff frequency Wn e stop for an order 2 n bandstop analog filter if Wn is a two element vector Wn wl w2 The stopband is wl lt lt w2 besself With different numbers of output arguments bessel f directly obtains other realizations of the analog filter To obtain zero pole gain form usethree output arguments z p k besself n Wn or z p k besse
453. s scaling units in Filter Viewer 5 26 5 77 in Spectrum Viewer 5 25 5 90 5 93 B band edges prewarping 2 43 bandlimited interpolation 6 276 bandpass filter analog prototype design 2 6 and impulse invariance 2 41 Bessel 6 16 Butterworth 6 29 6 31 Chebyshev type 6 51 6 53 Chebyshev type II 6 56 6 58 elliptic 6 110 6 112 example Chebyshev type 2 39 FIR design with window method 2 21 6 139 transformation from lowpass to 6 202 bandstop filter analog prototype design 2 6 Bessel 6 16 Butterworth 6 30 6 31 Chebyshev type 6 52 6 53 Chebyshev type II 6 57 6 58 elliptic 6 111 6 112 FIR design with window method 2 21 6 138 transformation from lowpass to 6 205 bandwidth 2 40 bartlett 42 6 7 613 compared tot ri ang 6 13 example 4 2 Bartlett window 4 2 coefficients 6 13 Bessel filter analog 6 16 analog prototype 2 11 2 38 6 15 Index bandpass configuration analog 6 16 bandstop configuration analog 6 16 characteristics 2 11 highpass configuration analog 6 16 limitations 6 18 lowpass configuration analog 6 16 besselap 2 5 6 9 6 15 example 2 11 besself 2 5 2 6 6 4 6 16 beta parameter of Kaiser window 5 65 bias correlation 3 3 4 12 power spectral density 3 11 spectral density 3 11 variance trade off 3 4 bilinear 2 5 2 41 2 42 6 10 6 20 bilinear transformation 2 42 6 20 defined 2 42 output representation 6 21 prewarping 2 43 6 20 blackman 4 2 6 7 6 25 Blackman window 4 4 6 25 defined 4 4
454. s1 2 17 6 5 6 147 firls 2 17 2 22 6 5 6 150 accessing from F ilter Designer 5 55 5 63 5 65 compared toremez 2 23 filter characteristics 6 153 for differentiator design 2 26 weight vector 2 24 firrcos 6155 firrcos 2 17 6 5 6155 fixed point implementation digital filter 1 37 fm 4 29 FM Seefrequency modulation fopen 1 13 Fourier transform eigenvector equivalent 3 24 Fourier transform time dependent See time de pendent F ourier transform Fourier transform See discrete Fourier trans form fast F ourier transform 1 11 Index fread 1 13 freqs 1 26 6 3 6 156 freqspace 6 159 frequency 6 256 analog xvii angular 2 2 carrier 4 28 6 218 6 322 center 2 40 cutoff 2 38 digital xvii normalization 2 2 Nyquist xvii 2 2 prewar ping 6 20 transformation 6 202 6 205 6 207 6 209 vector 2 24 6 141 6 144 6 333 frequency analysis in Filter Viewer 5 74 time dependent 6 284 Frequency Axis Range pop up menu in Prefer ences dialog box 5 25 5 27 Frequency Axis Scaling pop up menu in Prefer ences dialog box 5 25 5 26 frequency axis scaling in Spectrum Viewer 5 90 frequency demodulation 6 99 frequency domain duality with time domain 1 22 FIR filtering 1 19 for filter implementation 1 22 frequency domain based modeling See paramet ric modeling frequency estimator functions in eigenanalysis 3 23 frequency estimator techniques eigenvector EV method 3 22 multiple signal classification MUSIC method 3 22
455. scale factors of m n si ze X The execution time is fastest when m and n are powers of two and slowest when they are large primes ifft2 is part of the standard MATLAB environment fft One dimensional fast Fourier transform fft2 Two dimensional fast Fourier transform fftn N dimensional fast Fourier transform see the online MATLAB Function Reference fftshift Rearrange the outputs off ft andfft2 ifft One dimensional inverse fast Fourier transform ifftn N dimensional inverse fast Fourier transform see the online MATLAB Function Reference impinvar Purpose Impulse invariance method of analog to digital filter conversion Syntax bz az impinvar b a Fs bz az impinvar b a bz az impinvar b a Fs tol Description bz az impinvar b a Fs creates a digital filter with numerator and denominator coefficients bz and az respectively whose impulse response is equal to the impulse response of the analog filter with coefficients b anda scaled by 1 Fs bz az impinvar b a uses the default value of 1 Hz for Fs bz az impinvar b a Fs tol uses the tolerance specified by tol to determine whether poles are repeated A larger tolerance increases the likelihood thati mpi nvar will consider nearby poles to be repeated The default is 0 001 or 0 1 of a pole s magnitude Notethat the accuracy of the pole values is still limited to the accuracy obtainable by ther oot s function Example Convert an analog l
456. se P 2columns contain the cross covariance sequences for all combinations of the columns of xX By default xc ov computes raw covariances with no normalization For a length N vector N I ml 1 N 1 N 1 Gy 1 1 gt 0 x n x m N i Yn m N Yi Cxy m 4 n 0 i i 0 x cyx m m lt 0 X COV Examples The output vector has elements given by c m Cy m N m 1 2N 1 The covariance function requires normalization to estimate the function properly v xcov x option specifies a scaling option whereopti on is e biased for biased estimates of the cross covariance function e unbiased for unbiased estimates of the cross covariance function e coeff to normalize the sequence so the auto covariances at zero lag are identically 1 0 e none to usethe raw unscaled cross covariances default See 1 for more information on the properties of biased and unbiased correlation and covariance estimates c lags xcov x y maxlags wherex andy are length m vectors returns the cross covariance sequence in a length 2 maxl ags 1 vector c l ags isa vector of the lag indices wherec was estimated that is maxl ags maxlags c lags xcov x maxlags isthe autocovariance sequence over the range of lags maxlags maxlags c lags xcov x maxlags wherex is anm by p array returns array c with 2 maxl ags 1 rows whose P columns contain the cross covariance sequences for all combinations of the
457. second step in the analog prototyping design technique is the frequency transformation of a lowpass prototype The toolbox provides a set of functions totransform analog lowpass prototypes with cutoff frequency of 1 rad sec into bandpass highpass bandstop and lowpass filters of the desired cutoff frequency Special Topics in IIR Filter Design Freq Transformation Transformation Function Lowpass to lowpass numt dent p2lp num den Wo s s At Bt Ct Dt p2 p A B C D Wo Lowpass to highpass numt dent p2hp num den Wo At Bt Ct Dt p2hp A B C D Wo A OO S Lowpass to bandpass numt dent p2bp num den Wo Bw At Bt Ct Dt p2bp A B C D Wo Bw Wo s100 1 s By s 00 Lowpass to bandstop numt dent p2bs num den Wo Bw 5 0 At Bt Ct Dt p2bs A B C D Wo Bw S o s o 1 As shown all of the frequency transformation functions can accept two linear system models transfer function and state space form F or the bandpass and bandstop cases o 0103 and By 02 01 where is the lower band edge and is the upper band edge The frequency transformation functions perform frequency variable substitution In the case of p2bp and p2bs this is a second order substitution so the output filter is twice the order of the input For p21 p and p2hp the output filter is the same order as the input To begin designing an order 10 bandpas
458. semilogx w phase Toconvert to Hertz degrees and decibels use f wi 2 pi mag 20 10g10 mag phase phase 180 pi 6 157 freqs Algorithm f reqs evaluates the polynomials at each frequency point then divides the numerator response by the denominator response w s h polyval b s polyval a s See Also abs angle freqz invfreqs logspace polyval 6 158 Absolute value magnitude Phase angle Frequency response of digital filters Continuous time analog filter identification from frequency data Generate logarithmically spaced vectors see the online MATLAB Function Reference Polynomial evaluation See the online MATLAB Function Reference freqspace Purpose Syntax Description See Also Frequency spacing for frequency response f freqspace n f freqspace n whole f1 f2 freqspace n f1 f2 freqspace mn xl yl freqspace n meshgrid xl yl freqspace mn meshgrid freqspace returns the implied frequency range for equally spaced frequency responses This is useful when creating frequency vectors for use with f reqz f freqspace n returns the frequency vector f assumingn evenly spaced points around the unit circle For n even or odd f iS 0 2 n 1 Forn even freqspace returns n 2 2 points For N odd it returns n 1 2 points f freqspace n whole returnsn evenly spaced points around the whole unit circle In this case f
459. sh between the meanings of filter length and filter order The filter length is the number of impulse response samples in the FIR filter Generally the impulse response is indexed from n O ton L 1 whereL is the filter length The filter order is the highest power in a z transform representation of the filter For an FIR transfer function this representation is a polynomial in z where the highest power is z and the lowest power is 2 The filter order is 1 less than the length L 1 and is also equal to the number of zeros of the z polynomial The lengths of the frequency magnitude and deviation vectors must match otherwise kai serord gives the following error message Requires M and DEV to be the same length Length of F must be 2 length M 2 When magnitudes are not specified correctly kai serord gives the following error messages Stopbands must be zero All passbands must have the same height If the band edges are not strictly increasing kai serord gives the following error message Bandedges must be strictly increasing firl Window based finite impulse response filter design standard response kaiser Kaiser window remezord Parks McClellan optimal FIR filter order estimation 1 Kaiser J F Nonrecursive Digital Filter Design Using the g sinh Window Function Proc 19741EEE Symp Circuits and Syst April 1974 Pgs 20 23 2 IEEE Digital Signal Processing II IEEE Press New York J ohn Wiley
460. shev type filter It 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 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 Heredeci mate filters the input sequence in only one direction This technique conserves memory and is useful for working with long sequences y decimate x r n fir usesalengthn FIR filter Decimate a signal by a factor of four t 0 00025 1 time vector x sin 2 pi 30 t sin 2 pi 60 t y deci mate x 4 decimate View the original and decimated signals stem x 1 120 axis 0 120 2 2 original signal stem y 1 30 decimated signal Original Signal Decimated Signal 2 2 idl all ur ol appt 1 1 2 2 0 50 100 0 10 20 30 Algorithm deci mate uses decimation algorithms 8 2 and 8 3 from 1 1 It designs a lowpass filter By default deci mat e uses a Chebyshev type filter with normalized cutoff frequency 0 8 and 0 05 dB of passband ripple For thefir option deci mate designs a lowpass FIR filter with cutoff frequency 1 r usingfirt 2 For theFIR filter deci mate applies the filter to the input vector in one direction In thelIR case deci mat e ap
461. sired and actual frequency responses The filters are optimal in the sense that the maximum error between the desired frequency response and the actual frequency response is minimized Filters designed this way exhibit an equiripple behavior in their frequency responses and hence are sometimes called equiripple filters b remez n f a returns row vector b containing then 1 coefficients of the order n FIR filter whose frequency amplitude characteristics match those given by vectorsf anda The output filter coefficients taps in b obey the symmetry relation b k b n 2 k k 1 n 1 6 255 remez Vectorsf anda specify the frequency magnitude characteristics of the filter e f isavector of pairs of frequency points specified in the range between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency The frequencies must bein increasing order e a isa vector containing the desired amplitudes at the points specified inf The desired amplitude at frequencies between pairs of points f k f k 1 for k odd is the line segment connecting the points f k a k and f k 1 a k 1 The desired amplitude at frequencies between pairs of points f k f k 1 for k even is unspecified The areas between such points are transition or don t care regions e f anda must be the same length The length must be an even number The relationship between thef anda vectors in defining a desired frequency
462. sponse for each point inopt fgrid Weighting for each point inopt fgrid Actual frequency response for each point inopt fgrid Error at each pointinopt fgrid opt des opt H Vector of indices intoopt fgrid for extremal frequencies Vector of extremal frequencies 6 259 remez Example Algorithm 6 260 Graph the desired and actual frequency responses of a 17th order Parks McClellan bandpass filter f 0 0 3 0 4 0 6 0 7 1 a 00110 0 b remez 17 f a h w fregz b 1 512 plot f a w pi abs h 1 2 0 67 0 4F 0 2 remez is aMEX file version of the original Fortran code from 1 altered to design arbitrarily long filters with arbitrarily many linear bands remez designs typel II 111 and IV linear phase filters Typel and Typell are the defaults for n even and n odd respectively while Type III n even and Type lV n odd are obtained with the hil bert and differentiator flags The different types of filters have different symmetries and certain constraints on their frequency responses see reference 5 for more details remez Linear Phase Filter Response H f Response H f Filter type Order n Symmetry of Coefficients f 0 f 1 Nyquist Type Even even No restriction No restriction Type Odd b k b n 2 k k 1 n 1 Norestriction H 1 0 Type III Even odd H 0 0 H 1 0 Type lV Odd b k b n 2 k k 1 n 1 H 0 0 No restriction Diagnosti
463. ss filter prototype given by polynomial coefficients into a bandpass filter with center frequency Wo and bandwidth Bw Row vectorsb anda specify the coefficients of the numerator and denominator of the prototype in descending powers of s b s _ bA s b nn s b nn 1 as as 4 a nd s a nd 1 Scalars Wo and Bw specify the center frequency and bandwidth in units of radians second For a filter with lower band edgew1 and upper band edge w2 useWo sqrt wl w2 andBw w2 wl p2bp returns the frequency transformed filter in row vectors bt and at State Space Form At Bt Ct Dt p2bp A B C D Wo Bw converts the continuous time state space lowpass filter prototype in matricesA B C D x Ax Bu y Cx Du Ip2bp Algorithm into a bandpass filter with center frequency Wo and bandwidth Bw For a filter with lower band edgewl and upper band edge w2 useWo sqrt wl w2 and Bw w2 wl The bandpass filter is returned in matrices At Bt Ct Dt p2bp isa highly accurate state space formulation of the classic analog filter frequency transformation Consider the state space system x Ax Bu y Cx Du where u is the input x is the state vector and y is the output The Laplace transform of the first equation is sx Ax Bu Now if a bandpass filter is to have center frequency p and bandwidth B the standard s domain transformation is s Q p 1 p where Q B and p S w Substi
464. ss to lowpass analog filter transformation Ip2Ip Purpose Syntax Description Lowpass to lowpass analog filter transformation bt at p2 p b a Wo At Bt Ct Dt p2lp A B C D Wo p21 p transforms an analog lowpass filter prototype with a cutoff frequency of 1 rad sec into a lowpass filter with any specified cutoff frequency The transformation is one step in the digital filter design process for thebut ter cheby1 cheby2 andel lip functions The p2 p function can perform the transformation on two different linear system representations transfer function form and state space form In both cases the input system must be an analog filter prototype Transfer Function Form Polynomial bt at p2Ilp b a Wo transforms an analog lowpass filter prototype given by polynomial coefficients into a lowpass filter with cutoff frequency Wo Row vectorsb anda specify the coefficients of the numerator and denominator of the prototype in descending powers of s b s _ bs b nn s b nn 1 a s as 4 a nd s a nd 1 Scalar Wo specifies the cutoff frequency in units of radians second p21 p returns the frequency transformed filter in row vectorsbt andat State Space Form At Bt Ct Dt 1p2lp A B C D Wo converts the continuous time state space lowpass filter prototype in matricesA B C D x Ax Bu y Cx Du into a lowpass filter with cutoff frequency Wo p21 p returns the lowpass f
465. ssed or if fresp does not supply a default e even indicates a real and even impulse response This is the default for highpass lowpass bandpass bandstop and multiband designs e odd indicates a real and odd impulse response This is the default for Hilbert and differentiator designs e real indicates conjugate symmetry for the frequency response If any sym option other than none is specified the band edges should only be specified over positive frequencies the negative frequency region is filled in from symmetry If a sym option is not specified the fresp function is queried for a default setting b cremez skip_stage2 disables the second stage optimization algorithm which executes only when cr emez determines that an optimal solution has not been reached by the standard Remez error exchange Disabling this algorithm may increase the speed of computation but may incur a reduction in accuracy By default the second stage optimization is enabled b cremez debug enables the display of intermediate results during the filter design where debug may beoneof trace plots both or off By default itis set to off b cremez lgrid usestheinteger grid tocontrol the density of the frequency grid which has roughly 2 next pow2 1 grid n frequency points The default value for grid is25 Notethat the grid argument must bea 1 by 1 cell array Any combination of the sym skip_stag
466. step above to handle the matrix case fft One dimensional fast Fourier transform ifft One dimensional inverse fast Fourier transform rceps Real cepstrum and minimum phase reconstruction 1 Claerbout J F Fundamentals of Geophysical Data Processing New York McGraw Hill 1976 Pgs 59 62 6 171 icceps Purpose Syntax Description See Also References 6 172 Inverse complex cepstrum x icceps xhat nd x icceps xhat nd returns the inverse complex cepstrum of the assumed real sequence xhat removing nd samples of delay If xhat was obtained with cceps x then the amount of delay that was added tox was the element of round unwrap angle fft x pi corresponding tor radians cceps Complex cepstral analysis hilbert Hilbert transform rceps Real cepstrum and minimum phase reconstruction unwrap Unwrap phase angles 1 Oppenheim A V and R W Schafer Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 idct Purpose Syntax Description See Also Inverse discrete cosine transform X X idct y idct y n The inverse discrete cosine transform reconstructs a sequence from its discrete cosine transform DCT coefficients Thei dct function is the inverse of thedct function x idct y returns the inverse discrete cosine transform of y 2n 1 k 1 T ae x n wonko nse n 1 N k 1 where 1 k 1 w k JN 2 N 2 lt k lt N and N leng
467. stics of the filter response For information on frequency analysis using toolbox functions from the command line or from M files see F requency Response in Chapter 1 of this manual Opening the Filter Viewer Open or activate the Filter Viewer from SPT ool 1 Select one or more filters from the Filters list in SPTool 2 Press View in the Filters panel in SPTool The Filter Viewer is activated and the selected filters are loaded into the Filter Viewer and displayed 5 74 Using the Filter Viewer Interactive Filter Analysis Filter ID panel Plots panel including menus for modifying plot characteristics Frequency Axis panel Basic Filter Viewer Functions The Filter Viewer has the following components e A Plots panel for selecting which subplots display in the main plots window e A Rulers panel and line display controls for making signal measurements and comparisons e A Frequency Axis panel for specifying x axis scaling in the main plots window e A filter identification panel that displays information about the currently selected filter s e A main plots display area for viewing one or more frequency domain plots for the selected filter s e Zoom controls for getting a closer look at filter response characteristics When you first open or activate the Filter Viewer it displays the default plot configuration for the selected filter s View zoom controls Line display controls Tiha ieee AEE Fie ain s
468. stimate 10 T 1 Si fo We fo Power Spectrum Magnitude dB A 1 oO oO a D ro i oO 1000 2000 3000 4000 5000 Frequency 6 241 psd Algorithm Diagnostics See Also 6 242 psd calculates the power spectral density using Welch s method see references 1 and 2 1 It applies the window specified by the wi ndow vector to each successive detrended section of x 2 It transforms each section with an nf f t point FFT 3 It forms the periodogram of each section by scaling the magnitude squared of each transform 4 It averages the periodograms of the overlapping sections to form xx the power spectrum of x The number of sections that psd averages is k fix length x noverlap length wi ndow noverl ap An appropriate diagnostic message is displayed when incorrect arguments to psd are used Requires window s length to be no greater than FFT length Requires NOVERLAP to be strictly less than the window length Requires positive integer values for NFFT and NOVERLAP Requires confidence parameter to be a scalar between 0 and 1 Requires vector input cohere Estimate magnitude squared coherence function between two signals csd Estimate the cross spectral density CSD of two signals pburg Power spectrum estimate using the Burg method pmt m Power spectrum estimate using the multitaper method MTM pmusic Power spectrum estimate using MUSIC eigenvector meth
469. t it creates a sawtooth wave with peaks of 1 and 1 instead of a sine wave The sawtooth wave is defined to be 1 at multiples of 2x and to increase linearly with time with a slope of 1 n at all other times sawtooth t width generates a modified triangle wave wherewi dth a scalar parameter between 0 and 1 determines the fraction between 0 and 2x at which the maximum occurs The function increases from 1 to 1 on the interval 0 to 2n wi dt h then decreases linearly from 1 to 1 on the interval 2x wi dt h to 27 Thus a parameter of 0 5 specifies a standard triangle wave symmetric about time instant z with peak to peak amplitude of 1 sawt oot h t 1 is equivalent tosawtooth t If the wi dth parameter is not a scalar sawt oot h gives the following error message Requires W DTH parameter to be a scalar chirp Swept frequency cosine generator cos Cosine of vector matrix elements see the online MATLAB Function Reference diric Dirichlet or periodic sinc function gauspuls Gaussian modulated sinusoidal pulse generator pulstran Pulse train generator rectpuls Sampled aperiodic rectangle generator Sin Sine of vector matrix elements see the online MATLAB Function Reference sinc Sinc or sin xt rt function Square Square wave generator tripuls Sampled aperiodic triangle generator sinc Purpose Syntax Description Sinc function y sinc x si nc computes the sinc function of an input vector or array wher
470. ted all selected signals are displayed in the main axes display area and in the panner The elements of the selected signals are plotted versus an equally spaced time vector in both the main axes display and the panner E Signal Browser BEE File Options Window sray Signa i Ful 2 pa i gt gt Selection WW Use i om Om om Om gt pe ted reap P ED p ce Hep Lmt cl Color mtlb 4001 by 1 real Fs 7418 Rulers fo x1 0 1797 y1 1 3435 2 0 35953 y2 0 38843 dx 0 17983 dy 1 7319 o 0 1 0 2 03 0 4 0 5 Time nnn Save Rulers Panner 5 47 5 Interactive Tools 5 48 When the variable is a vector one signal is displayed as in the example above It is automatically selected and its name size type and sampling frequency are displayed above the main axes display the name is also highlighted in the Selection pop up menu When more than one signal is selected each signal is displayed in a different color in both the main axes display and the panner EJ Signal Browser BEE File Options Window z lt Selection sariez ie Full gt lt ab Maa Zoom Zoom Zoom Zoom f d Zom Miewl my Out nX _Out x Help me Geek Rulers bP af 1 0 17969803 y1 1 3435103 x2 0 35953087 y2 0 38842729 dx 0 17983284 dy 1 7319376 o 0 1 0 2 0 3 0 4 0 5 Time pe Aegina Sahar Save Rulers The names
471. ted signal for example you can export the signal information to the workspace or to disk using Export from the File menu in SPTool Thesignal information is stored in a structure that you can access to retrieve the signal data and sample frequency The signal structure also contains a number of fields that are used internally by SPTool 5 53 5 Interactive Tools 5 54 Toseethefields of the signal structure try exporting a signal tothe workspace 1 Import asignal into SPTool if there are none currently loaded see Importing Signals Filters and Spectra on page 5 8 Label the imported signal si g1 2 Export the signal Select Export from the File menu 3 In the Export dialog box select si g1 and press the Export to Workspace button 4 Typewho atthe MATLAB command line to look at the variables in the workspace The variable called si g1 is the signal structure you exported from SPTool 5 Typesig1 at the command line to list the fields of the signal structure Thedata andFs fields of the signal structure contain the information that defines the signal The other fields are used internally by SPTool and are subject to change in future releases e Thedata field is a vector or array containing the signal s data e TheFs field contains the sample frequency of the signal in Hertz Using the Filter Designer Interactive Filter Design Using the Filter Designer Interactive Filter Design The Filter Designer
472. ter frequency transformation If a bandstop filter is to have center frequency wy and bandwidth B the standard s domain transformation is ees Qp 1 where Q B and p S The state space version of this transformation is Q Wo Bw At Wo Q inv A Wo eye ma Wo eye ma zeros ma Bt Wo Q A B zeros ma nb Ct C A zeros mc ma Dt D C A B See p2bp for a derivation of the bandpass version of this transformation bilinear Map variables using bilinear transformation i mpi nvar Impulse invariance method of analog to digital filter conversion p2bp Lowpass to bandpass analog filter transformation p2hp Lowpass to highpass analog filter transformation p2lp Lowpass to lowpass analog filter transformation Ip2hp Purpose Syntax Description Lowpass to highpass analog filter transformation bt at p2hp b a Wo At Bt Ct Dt p2hp A B C D Wo p2hp transforms analog lowpass filter prototypes with a cutoff frequency of 1 rad sec into highpass filters with desired cutoff frequency The transformation is one step in the digital filter design process for thebut ter cheby1 cheby2 andel lip functions The p2hp function can perform the transformation on two different linear system representations transfer function form and state space form In both cases the input system must be an analog filter prototype Transfer Function Form Polynomial bt at p2hp b
473. ter order selection cheblord Chebyshev type filter order selection cheb2ord Chebyshev type II filter order selection ellipord Elliptic filter order selection kaiserord Estimate parameters for an FIR filter design with Kaiser window remez Parks McClellan optimal FIR filter design 6 265 remezord References 6 266 1 Rabiner L R and O Herrmann The Predictability of Certain Optimum Finite Impulse Response Digital Filters IEEE Trans on Circuit Theory Vol CT 20 No 4 J uly 1973 Pgs 401 408 2 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 156 157 resample Purpose Syntax Description Change sampling rate by any factor y resample x p q y resample x p q n y resample x p q n beta y resample x p q b y b resampl e x p q y resample x p q resamples the sequence in vector x at p q times the original sampling rate using a polyphase filter implementation The length of y is equal tocei ength x p q p andq must be positive integers Ifx isa matrix r esampl e works down the columns of x resample applies an anti aliasing lowpass FIR filter tox during the resampling process It designs the filter using f i r1 with a Kaiser window y resample x p q n usesn terms on either side of the current sample x k to perform the resampling The length of the FIR filter r
474. th y hilbert x where the real part of y is the original real data and the imaginary part is the actual Hilbert transform y is sometimes called the analytic signal in reference to the continuous time analytic signal A key property of the discrete time analytic signal is that its z transform is 0 on the lower half of the unit cirde Many applications of the analytic signal are related to this property for example the analytic signal is useful in avoiding aliasing effects for bandpass sampling operations The magnitude of the analytic signal is the complex envelope of the original signal 4 37 4 Special Topics The Hilbert transform is related to the actual data by a 90 phase shift sines become cosines and vice versa To plot a portion of data solid line and its Hilbert transform dotted line t 0 1 1023 1 x sin 2 pi 60 t y hilbert x plot t 1 50 real y 1 50 hold on plot t 1 50 imag y 1 50 hold off 1 0 8 J 0 6 J 0 4 J 0 2 J 0 af 0 2 J 0 4 J 0 6 J 0 8 J ar 0 01 0 02 0 03 0 04 0 05 The analytic signal is useful in calculating instantaneous attributes of a time series the attributes of the series at any point in time The instantaneous amplitude of the input sequence is the amplitude of the analytic signal The instantaneous phase angle of the input sequence is the unwrapped ang e of the analytic signal the instantaneous frequency is the time rate of change of thei
475. th x which isthe sameasli engt h y The series is indexed from n 1 and k 1 instead of the usual n 0 and k 0 because MATLAB vectors run from 1 to N instead of from 0 to N 1 x idct y n appends zeros or truncates the vector y to length n before transforming Ify isa matrix i dct transforms its columns dct Discrete cosine transform DCT dct2 Two dimensional DCT see mage Processing T ool box U ser s Guide idct2 Two dimensional inverse DCT see mage Processing T ool box User s Guide ifft One dimensional inverse fast Fourier transform 6 173 idct References 1 ain A K Fundamentals of Digital I mageProcessing Englewood Cliffs NJ Prentice Hall 1989 2 Pennebaker W B and J L Mitchell J PEG Still I mage Data Compression Standard New York NY Van Nostrand Reinhold 1993 Chapter 4 6 174 Purpose Syntax Description Algorithm See Also One dimensional inverse fast Fourier transform ifft x ifft x n y y i f ft computes the inverse Fourier transform of a vector or array This function implements the inverse transform given by N 1 x n 1 1 N Xk Dwg k 0 where Wy e 2P N and N engt h x Notethat theseries isindexedasn 1 and k 1instead of the usual n and k because MATLAB vectors run from 1 to N instead of from 0 to N 1 y ifft x istheinverse Fourier transform of vector x Ifx isan array y is the inverse FFT of each column of the matrix
476. the default values shown above Ifx isreal psd estimates the spectrum at positive frequencies only in this case the output Pxx is a column vector of length nf ft 2 1 fornfft even and nfft 1 2 fornfft odd Ifx is complex psd estimates the spectrum at both positive and negative frequencies and Pxx has length nf ft Pxx psd x nfft uses the specified FFT length nf ft in estimating the power spectrum for x Specify nf ft as a power of 2 for fastest execution Pxx f psd x nfft Fs returns a vector f of frequencies at which the function evaluates the PSD f isthesamesizeasPxx soplot f Pxx plots the power spectrum versus properly scaled frequency Fs has no effect on the output Px x it is a frequency scaling multiplier 6 239 psd 6 240 Pxx psd x nfft Fs window specifies a windowing function and the number of samples per section of thex vector If you supply a scalar for wi ndow psd uses a Hanning window of that length The length of the window must be less than or equal tonf f t ps d zero pads the sections if the length of the window is less than nf ft psd returns an error if the length of the window is greater than nfft Pxx psd x nfft Fs window noverlap overlaps the sections of x by noverl ap samples You can use the empty matrix to specify the default value for any input argument except x For example psd x 10000 is equivalent to psd x but with a sampling frequency of 10 000 Hz instead of the
477. the filter specifications are contained in thef dkaiser field which is itself a data structure The specifications includethe parameter values from the Specifications panel of the Filter Designer such as band edges and filter order For example the Kaiser window filter above has the following specifications stored in specs fdkaiser setOrderFlag 0 type 1 f 0 0 1000 0 1500 1 Rp 3 Rs 20 Wn 0 1250 order 34 Beta 0 wind 35x1 double Since certain filter parameters are uniquetoa particular design this structure has a different set of fields for each filter design For example theBet a field above only appearsin thes pecs structureif the design is a Kaiser window FIR filter 5 71 5 Interactive Tools 5 72 The table below lists the possible specifications fields that can appear in the export structure and describes their contents Parameter Description Beta f Fass Fstop order Rp Rs set OrderFl ag type w3db wind Wn wt Kaiser window B parameter Contains a vector of band edge frequencies normalized to 1 i e 1 Nyquist Passband cutoff frequencies Scalar for lowpass and highpass designs two element vector for bandpass and bandstop designs Stopband cutoff frequencies Scalar for lowpass and highpass designs two element vector for bandpass and bandstop designs The response magnitudes corresponding to the band edge frequencies inf Filter order
478. the frequency bands over which optimization is performed note that there are two transition bands from 0 5 to 0 4 and from 0 3 to 0 4 In either case the frequency response is obtained and plotted using linear scale h w fregz b 1 512 whole plot w pi 1 fftshift abs h Note that the frequency response has been calculated over the entire normalized frequency range 1 1 by passing the option whole tofreqz In order to plot the negative frequency information in a natural way the response has been wrapped just as FFT data is usingfftshift 5 T Magnitude Response wo A w oa A oa NS a 2 33 2 Filter Design The filter response for this multiband filter is complex which is expected because of the asymmetry in the frequency domain The filter response is 2 5 T 2 4 1 57 J t a w IF 7 0 57 7 RAAE J fetesteteteseeee 0 5 L L L L L L L 0 5 10 15 20 25 30 35 40 0 2 T t Ol eee eee L ef ooe ee 9 g ee a Jae 0 2 0 5 10 15 20 25 30 35 40 Filter Design with Reduced Delay Consider the design of a 62 tap lowpass filter with a half N yquist cutoff If we specify a negative offset value to the owpass filter design function the group delay offset for the design is significantly less than that obtained for a standard linear phase design This filter design may be computed as follows b cremez 61 0 0 5
479. the mouse button and drag the mouse Click and drag panning is not enabled in mouse zoom mode Making Spectrum Measurements Use the rulers to make a variety of measurements on the selected spectrum See Making Signal Measurements on page 5 37 for details Using the Spectrum Viewer Interactive PSD Analysis Viewing Spectral Density Plots Spectral density estimation is a technique that finds the approximate frequency content of a signal The Spectrum Viewer calculates single channel power spectral density PSD When you first generate a spectrum the Spectrum Viewer shows a default power spectral density function of the input data By default the Spectrum Viewer uses the Burg method of PSD computation with an order of 10 and an FFT length of 1024 You can change plot properties and computation parameters for a displayed spectrum and you can set confidence intervals Controlling and Manipulating Plots Changing Plot Properties You can control the axes units and scaling properties that affect the Spectrum Viewer s plots Use the Options menu to select e Linear or decibel scaling for the magnitude axis e Linear or logarithmic scaling for the frequency axis e The frequency range to view See Options Menu on page 5 90 for details You can also zoom in on any of the Spectrum Viewer s plots See Zoom Controls on page 5 30 for details You can set other scaling properties in the Parameters panel dependi
480. the same number of columns then the i th column ofk is used to filter the i th column of x A signal matrix is returned f g latcfilt k v x filtersx with thelIR lattice coefficients k and ladder coefficients v k and v must be vectors whilex may bea signal matrix f g latcfilt k 1 x filtersx with thelIR all polelattice specified by k k andx may be vectors or matrices according to the rules given for the FIR lattice filter Filter data with a recursive IIR or nonrecursive FIR filter latc2tf Lattice filter to transfer function conversion tf2l atc Transfer function to lattice filter conversion levinson Purpose Syntax Description Algorithm See Also References Levinson Durbin recursion a levinson r n TheLevinson Durbin recursion is an algorithm for finding an all pole IHR filter with a prescribed deterministic autocorrelation sequence It has applications in filter design coding and spectral estimation The filter that evi nson produces is minimum phase a levinson r n findsthe coefficients of annth order autoregressivelinear process which hasr as its autocorrelation sequence r is a real or complex deterministic autocorrelation sequence a vector andn is the order of denominator polynomial A z thatis a 1 a 2 a n 1 Thefilter coefficients are ordered in descending powers of z H z a n A 1sa 2zt sa n hz levi nson solves the symmetric Toeplitz system of linear equat
481. tible to frequency shifts relative to the true frequency resulting from the initial phase of noisy sinusoidal signals This effect is magnified when analyzing short data sequences The toolbox function pburg implements the Burg method 3 21 3 Statistical Signal Processing Compare the spectrum of a noisy signal computed using the Burg method and the Welch method Fs t 0 Xn P1 f P2 f pl ot axis legen 30 1000 1 Fs 1 sin 2 pi 50 t 2 sin 2 pi 120 t psd xn 1024 Fs pburg xn 17 1024 Fs 17th order model f 10 1og10 P1 f 10 10g10 P2 grid 0 200 25 30 d Welch Burg randn size t 257 j Welch Burg H eal 1 L 50 100 150 200 Note that as the model order for the Burg method is reduced a frequency shift due to the initial phase of the sinusoids will become apparent MUSIC and Eigenvector Analysis Methods Thep musi c function provides two related spectral analysis methods e The multiple signal classification method MUSIC developed by Schmidt e The eigenvector EV method developed by J ohnson See Marple 2 pgs 373 378 for a summary of these methods Both of these methods are frequency estimator techniques based on eigenanalysis of the autocorrelation matrix This type of spectral analysis 3 22 Spectral Analysis categorizes the information in a correlation or data matrix assigning information to eithe
482. tice Hall 1989 fftshift Purpose Syntax Description Example See Also Rearrange the outputs of the FFT functions fftshift x iT y fftshift x rearranges the outputs off ft andfft2 by moving the zero frequency component tothe center of the spectrum which is sometimes a more convenient form For vectors f ftshift x returns a vector with the left and right halves swapped For arrays f ft shift x Swaps quadrants one and three with quadrants two and four This function is part of the standard MATLAB environment For any array x Y fft2 x hasY 1 1 sum sum X theDC component of thesignal is in the upper left corner of the two dimensional FFT For Z fftshift yY the DC component is near the center of the matrix fft One dimensional fast Fourier transform fft2 Two dimensional fast Fourier transform 6 129 filter Purpose Syntax Description 6 130 Filter data with a recursive IIR or nonrecursive FIR filter y filter b a x y zf filter b a x are filter b a x zi IERI filter b a x zi dim filter ispart ofthe MATLAB environment It filters data using a digital filter The filter realization is the transposed direct form II structure 1 which can handle both FIR and IIR filters Ifa 1 1 filter normalizes the filter coefficients by a 1 If a 1 0 the input isin error y filter b a x filters the data in vector x with the filter described by c
483. ting to zero pole gain 6 298 defined 1 34 in SPTool 5 13 representing in MATLAB 1 34 statistical operations 3 2 Stay in Zoom mode After Zoom check box in Pref erences dialog box 5 24 5 25 5 27 5 28 Steiglitz M cBride iteration 6 301 Steiglitz M cB ride method 4 14 1 23 Index step response 5 18 viewing in Filter Viewer 5 87 Step Response check box Filter Viewer 5 77 step response plot 5 77 5 87 stmcb 2 5 4 10 4 14 6 8 6 301 stopband attenuation setting in Filter Designer 5 62 equiripple 2 10 strip plot 6 304 defined 6 304 strips 6 2 6 304 structure digital filter lattice 1 37 transposed direct form II 1 17 subplots 5 74 in Filter Viewer 5 76 subspace thresholds controlling in p musi c func tion 3 24 svd inpmusi c function 3 24 swept frequency cosine generator See chirp system identification 4 13 system models 1 32 and bilinear transformation 2 43 and filter design functions 2 7 and frequency transformation functions 2 39 T tapers in PSD estimates 3 16 taps 2 17 texts related 1 46 tf2l atc 1 39 1 42 6 4 6 306 tf2ss 1 42 6 4 6 307 tf2zp 6 309 tf2zp 1 42 6 299 6 309 tfe 3 6 3 14 6 7 6 311 thresh 3 24 tiling 5 79 tiling display in Filter Viewer 5 27 tiling preferences in Filter Viewer 5 21 Time Response Length edit box in Preferences dia log box 5 26 time response length in Filter Viewer 5 26 time vector 1 6 returned by modul ate 4 29 time dependent F ourier transform 4 26 ti
484. tofiltfilt 1 21 final condition parameters 1 17 implementation 1 17 initial condition parameters 1 17 initial conditions 6 135 filter design in Filter Designer 5 55 5 63 5 66 standard band configurations 5 55 using specification lines 5 62 Filter Designer 5 2 5 18 5 55 5 56 6 290 activating 5 18 5 56 changing plot properties 5 28 Classical IIR filter design 5 66 dosing 5 56 customizing 5 21 magnitude plot 5 62 magnitude plot as design tool 5 68 magnitude response plot 5 59 measuring response characteristics 5 62 saving data to workspace 5 53 5 69 5 98 setting edge frequencies 5 62 setting passband ripple 5 62 setting stopband attenuation 5 62 single band FIR filter design 5 63 window 5 56 filter parameters in Filter Viewer 5 21 filter response peaks and valleys 5 36 filter type design 5 15 5 18 imported 5 15 5 18 Filter Viewer 5 2 5 17 5 74 6 291 activating 5 17 5 74 customizing 5 21 default plot 5 75 plots 5 76 preferences 5 76 settings 5 76 subplots 5 76 viewing frequency response 5 73 viewing group delay 5 84 viewing impulse response 5 85 viewing magnitude response 5 80 viewing phase response 5 82 viewing step response 5 87 viewing zero pole plot 5 85 window 5 75 filter2 6 3 6 133 filtering and convolution 1 14 anti causal 1 20 frequency domain 1 22 initial conditions 1 17 generating 1 18 zero phase 1 20 filtering algorithm 5 19 Index filtfilt 1 19 1 20 2 4 6 3 6 134 compared tofilter
485. tor Sampled aperiodic rectangle generator Sawtooth or triangle wave generator Sine of vector matrix elements See the online MATLAB Function Reference Sinc or sin xt ct function Sampled aperiodic triangle generator 6 293 SS2SOS Purpose Syntax Description 6 294 State space to second order section conversion sos ss2sos A B C D sos s2s0s A B C D iu sos s2s0s A B C D order sos s2s0s A B C D iu order ss2sos converts a state space representation of a given system to an equivalent second order section representation sos s2s0s A B C D findsamatrixsos in Second order section form that is equivalent to the state space system represented by input arguments A B C andD Theinput system must be single input and real sos is an L by 6 matrix bor biy 421 aor 1 421 bo2 12 bn ap 412 922 SOS bor On b2L aL UL ML whose rows contain the numerator and denominator coefficients b and a of the second order sections of H z Il Il bok biz boyz byez bopz H z H z Ok 1k 5 2k aa Ak TAK a2kz k 1 sos s2s0s A B C D iu specifies a scalar i u that determines which output of the state space system A B C D is used in the conversion The default for i u is 1 sos ss2sos A B C D order and sos s2s0s A B C D iu order specify the order of the rowsinsos whereorder is e down toorder the sections so the first row ofs os contains the poles closest to the un
486. tor of length 5 h 1 1 1 1 4 length 4 averaging filter y conv h x Filter Implementation and Analysis Filters and Transfer Functions In general the z transform Y z of a digital filter s output y n is related to the z transform X z of the input by bA b b nb 4 z Y z H z X z EA a 1 a 2 z a na 1 z X z where H z is the filter s transfer function Here the constants b i and a i are the filter coefficients and the order of the filter is the maximum of na and nb NOTE The filter coefficients start with subscript 1 rather than 0 This reflects MATLAB s standard indexing scheme for vectors MATLAB stores the coefficients in two vectors one for the numerator and one for the denominator By convention MATLAB uses row vectors for filter coefficients Filter Coefficients and Filter Names Many standard names for filters reflect the number of a and b coefficients present e Whennb 0 that is b is a scalar the filter is an Infinite mpulse Response IIR all pole recursive or autoregressive AR filter e When na 0 that is a is a scalar the filter is a Finite mpulse Response FIR all zero nonrecursive or moving average MA filter e If bothna andnb are greater than zero the filter is an IIR pole zero recursive or autoregressive moving average ARMA filter The names AR MA and ARMA are usually applied to filters associated with filtered stochastic processe
487. tor or matrix x The Dirichlet function is _pka D x 2nk k 0 1 2 diric x E gt otherwise nsin x 2 where n is a user specified positive integer For n odd the Dirichlet function has a period of 27 for n even its period is 4r The magnitude of this function is 1 n times the magnitude of the discrete time F ourier transform of the n point rectangular window To plot the Dirichlet function over the range 0 to 4x forn 7 andn 8 use x linspace 0 4 pi 300 plot x diric x 7 plot x diric x 8 n 7 n 8 1 1 0 8 0 6 0 5 0 4 0 0 2 R N HV 0 5 0 2 0 4 1 0 5 10 15 0 5 10 15 W orking with Data Working with Data The examples in the preceding sections obtain data in one of two ways e By direct input that is entering the data manually at the keyboard e Usinga MATLAB or toolbox function such aSsin cos sawtooth square or sinc Some applications however may need to import data from outside MATLAB Depending on your data format you can do this in the following ways e Loading data from an ASCII fileor MAT file with MATLAB s oad command e Reading the data into MATLAB with a low level file I O function such as fopen fread andfscanf e Developing a MEX file to read the data Other resources are also useful such as a high level language program in Fortran or C for example that converts your data into MAT file format see theMATLAB Application Programmin
488. tor w containing the length n Chebyshev window whose F ourier transform magnitude sidelobe rippleisr dB below the mainlobe magnitude bartlett Bartlett window blackman Blackman window boxcar Rectangular window hammi ng Hamming window hanning Hanning window kaiser Kaiser window triang Triangular window 1 IEEE Programs for Digital Signal Processing IEEE Press New York J ohn Wiley amp Sons 1979 Program 5 2 cheby1 Purpose Syntax Description Chebyshev type filter design passband ripple b a chebyl n Rp Wn b a chebyl n Rp Wn ftype b a chebyl n Rp Wn s b a chebyl n Rp Wn ftype s z p k chebyl A B C D chebyl cheby1 designs lowpass bandpass highpass and bandstop digital and analog Chebyshev type filters Chebyshev type filters are equiripplein the passband and monotonic in the stopband Type filters roll off faster than type II filters but at the expense of greater deviation from unity in the passband Digital Domain b a chebyl n Rp Wn designs an order n lowpass digital Chebyshev filter with cutoff frequency Wn and Rp dB of ripple in the passband It returns the filter coefficients in the length n 1 row vectors b anda with coefficients in descending powers of z Bz _ bd BDz nt Dz A z 1 a 2 z7 a n 1 z H z Cutoff frequency is the frequency at which the magnitude response of the filter is equal to Rp d
489. trations v Pxx Pxxc f pmtm x dpss_params nfft Fs method p returns the PSD estimate xx the confidence interval Px xc and the frequency vector f from the data tapers computed using dps s with parameters from the cell array dpss_params whose first element is the second input todpss The first dpss parameter n is determined by the length of x For example pmt mx 3 5 trace 512 Fs calculatestheSlepian sequences for nw 3 5 and displays the method that dpss uses Seedpss for other options pmt m with no output arguments plots the PSD in the current or next available figure with confidence intervals Touse default parameters for any argument in an expression insert an empty matrix For example pmt mx 1000 uses defaults for the second and third elements in this case nw andnfft 6 225 pmtm Example This example analyzes a sinusoid in white noise Fs 1000 t 0 1 Fs 0 3 x cos 2 pi t 200 randn size t Pxx Pxxc f pmtm x 3 5 512 Fs 0 99 plot f 10 l oglO Pxx Pxxc 20 en 15 ey 10 PA BE OF 5 H 10 1 1 1 1 0 100 200 300 400 500 See Also dpss Discrete prolate spheroidal sequences Slepian sequences pburg Power spectrum estimate using the Burg method pmusic Power spectrum estimate using MUSIC eigenvector method psd Estimate the power spectral density PSD of a signal using Welch s method pyul ear Power spectrum estimate using Y
490. ts component tools Or you can skip the example read through the rest of this section from Basic SPTool Functions to Using the Signal Browser Interactive Signal Analysis and then work through the example Using SPTool 2 Example Importing Signal Data from a MAT File This example uses the sample file mt b mat which isin thet oo box signal directory 1 Select Import from the File menu The Import window is displayed 2 Make sure that Signal is displayed in the Import As pop up menu 3 Click on the From Disk radio button You can either enter a MAT file name or click Browse to open thefile dialog box and select a MAT file 4 Toget started type the file name mt b and press Tab or Enter Return on Macintosh Note that SPTool adds the mat extension automatically The data from the file you selected is displayed in the File Contents list In this example mt b is the signal data and fs is the sampling frequency Notice that si g1 is displayed in the Name field This is the default name of the imported signal 5 Click on mt I b to select it and then click on the arrow at the left of the Data field mt b is transferred to the Data field 5 5 5 Interactive Tools 5 6 6 Click onFs to select it and then click on the arrow at the left of the Sampling Frequency field Fs is transferred to the Sampling Frequency field 7 Click OK The signal has been imported into SPTool with the
491. ts in a list or multiple separate data objects in a list You may also have data objects simultaneously selected in different lists e Toselect a single unselected data object click on it All other data objects in that list box become unselected e Toadd or remove a range of data objects Shift click on the data objects at the top and bottom of the section of the list that you want to add e Toadd a single data object toa selection or remove a single data object from a multiple selection Ctrl click PC and UNIX or Command click Macintosh on the object Instead of Ctrl click you can use the right mouse button Editing Data Objects in SPTool The Edit menu entries are only available when there is at least one selected data object signal filter or spectrum in SPTool Use the Edit menu to duplicate and clear objects in SPTool and to edit object names and change sampling frequencies A signal filter or spectrum must be selected in order to be edited When you click on an Edit menu entry all sd ected data objects are displayed in a pop up menu To edit an SPTool object 1 Select a signal filter or spectrum 2 Click the appropriate Edit menu function The pop up menu shows the names of all selected data objects 3 Drag to choose a specific signal filter or soectrum for editing Duplicate Use Duplicate from the Edit menu to make a copy of the selected signal filter or spectrum in SPTool Click Duplicate and drag to c
492. turns the cross correlation of matricesA and B with no scaling xcorr2 is the two dimensional version of xcorr It has its maximum value when the two matrices are aligned so that they are shaped as similarly as possible xcorr2 A isthe autocorrelation matrix of input matrix A It is identical to xcorr2 A A conv2 Two dimensional convolution filter2 Two dimensional digital filtering xcorr Cross correlation function estimate 6 329 X COV Purpose Syntax Description 6 330 Cross covari ance function estimate equal to mean removed cross correlation v xcov x y v xcov x v xcov x option c lags xcov x y maxl ags c lags xcov x maxl ags c lags xcov x y maxlags option xcov estimates the cross covariance sequence of random processes Autocovariance is handled as a special case The true cross covariance sequence is the mean removed cross correlation sequence Dym Efan My XYn m 7 my where m and my are the mean values of the two stationary random processes and E fis the expected value operator xcov estimates the sequence because in practice access is available to only a finite segment of the infinitelength random process v xcov x y returns the cross covariance sequence in a length 2N 1 vector wherex andy arelength N vectors v xcov x is the autocovariance sequence for the vector x Wherex is an N by P array v xcov X returns am array with 2N 1 rows who
493. tuting this for s in the Laplace transformed state space equation and considering the operator p as d dt QX Qx Ax Bu or Ox Ax B Qx Now define OW Qx which when substituted leads to Qx Ax QO Bu 6 203 Ip2bp See Also 6 204 The last two equations give equations of state Write them in standard form and multiply the differential equations by to recover the time frequency scaling represented by p and find state matrices for the bandpass filter Q Wo Bw ma na size A At Wo A Q eye ma na eye ma na zeros ma na Bt Wo B Q zeros ma nb Ct C zeros mc ma Dt d Iftheinputtol p2bp isin transfer function form the function transforms it into state space form before applying this algorithm bilinear Map variables using bilinear transformation i mpi nvar Impulse invariance method of analog to digital filter conversion p2bs Lowpass to bandstop analog filter transformation p2hp Lowpass to highpass analog filter transformation p2lp Lowpass to lowpass analog filter transformation Ip2bs Purpose Syntax Description Lowpass to bandstop analog filter transformation bt at p2bs b a Wo Bw At Bt Ct Dt p2bs A B C D Wo Bw p2bs transforms analog lowpass filter prototypes with a cutoff frequency of 1 rad sec into bandstop filters with desired bandwidth and center frequency The transformation is one step in the digital f
494. tx Purpose Syntax Description Example Algorithm See Also 6 102 Discrete Fourier transform matrix A dftmtx n A discreeF ourier transform matrix is a complex matrix of values around the unit circle whose matrix product with a vector computes the discrete F ourier transform of the vector A dftmtx n returns then by n complex matrix A that when multiplied into a length n column vector x y A X computes the discrete F ourier transform of x The inverse discrete Fourier transform matrix is Ai conj dftmtx n n In practice the discrete Fourier transform is computed more efficiently and uses less memory with an FFT algorithm x TS 256 yl fft x than by using the Fourier transform matrix n length x y2 x dftmtx n norm yl y2 ans 2 0016e 09 df t mt x uses an outer product to generate the transform matrix convmt x Convolution matrix fft One dimensional fast Fourier transform Purpose Syntax Description Diagnostics See Also Dirichlet or periodic sinc function y diric x n y diric x n returns a vector or array y the same size as x The elements of y arethe Dirichlet function of the elements of x n must bea positive integer The Dirichlet function or periodic sinc function is 1407 x 2nk k 0 1 2 diric x 5 sin nx 2 cies nsin x 2 for any nonzero integer n This function has period 2x for n odd and period 4x for n even Its peak value
495. ues Cambridge Cambridge University Press 1993 9 Proakis J G and D G Manolakis Digital Signal Processing Principles Algorithms and Applications Upper Saddle River NJ Prentice Hall 1996 10 Rabiner L R and B Gold Theory and Application of Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 11 Welch P D TheUseof Fast Fourier Transform for the Estimation of Power Spectra A Method Based on Time Averaging Over Short Modified Periodograms IEEE Trans Audio Electroacoust Vol AU 15 J une 1967 Pgs 70 73 1 46 Filter Design Filter Requirements and Specification 2 2 IIR Filter Design 000 ccc ee 2 4 Classical IIR Filter Design Using Analog Prototyping 2 6 Comparison of Classical IIR Filter Types 2 8 FIR Filter Design 00 0 0 c eee eee 2 16 Linear Phase Filters 0 000 c eee eee eee 2 17 Windowing Method 000 e eee eee 2 18 Multiband FIR Filter Design with Transition Bands 2 22 Constrained Least Squares FIR Filter Design 2 27 Arbitrary Response Filter Design 0000e sees 2 31 Special Topicsin IIR Filter Design 2 37 Analog Prototype Design 00 cece eee 2 38 Frequency Transformation 00 00 cee eee ee 2 38 Filter Discretization 0 0 00 cece eee 2 41 References 23 0356 bipeeg orl eek aa ie 2 45 2 Filter Design
496. ues specified in array t after removing a scalar argument offset taken from the vector d Note that f unc must bea vectorized function that can take an arrayt as an argument An optional gain factor may be applied to each delayed evaluation by specifying d as atwo column matrix with the offset defined in column 1 and associated gain in column 2 of d Note that a row vector will be interpreted as specifying delays only pulstran t d func pl p2 allows additional parameters to be passed to f unc as necessary For example func t d 1 pl p2 func t d 2 pl p2 4 pulstran t d p Fs generates a pulse train that is the sum of multiple delayed interpolations of the prototype pulse in vector p sampled at the rate Fs wherep spans thetimeinterval 0 ength p 1 Fs andits samples are identically 0 outside this interval By default linear interpolation is used for generating delays pulstran pulstran t d p assumes that the sampling rateFs is equal to 1 Hz pulstran func specifies alternative interpolation methods See interpl for alist of available methods Examples This example generates an asymmetric sawtooth waveform with a repetition frequency of 3 Hz and a sawtooth width of 0 1 sec It has a signal length of 1 sec and a 1 kHz sample rate 0 1 7 Te3 15 1 kHz sample freq for 1 sec aN ac LS As 3 Hz repetition freq pulstran t d tripuls 0 1 1 ot t y Set a E e SE 0 9F 4 0 87
497. uires positive integer values for NFFT and NOVERLAP Requires vector input See Also cohere Estimate magnitude squared coherence function between two signals csd Estimate the cross spectral density CSD of two signals psd Estimate the power spectral density PSD of a signal using Welch s method tfe Transfer function estimate from input and output 6 287 specgram References 1 Oppenheim A V and R W Schafer Discre teTime Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 713 718 2 Rabiner L R and R W Schafer Digital Processing of Speech Signals Englewood Cliffs NJ Prentice Hall 1978 6 288 sptool Purpose Interactive digital signal processing tool SPT ool Syntax sptool Description Thesptool command invokes a suite of graphical user interface GUI tools that provides access to many of the signal filter and spectral analysis functions in the toolbox in a powerful easy to use interactive signal display and exploration environment Using SPTool you can import export and manage signals filters and spectra From SPTool you can activate its four integrated signal processing tools e The Signal Browse for viewing measuring and analyzing time domain information of imported signals oe Seema Breet mib mhi 6 289 sptool 6 290 e The Filter Designer for designing and editing FIR and IIR filters of various lengths and types with standard lowpass
498. ule Walker AR method References 1 Percival D B and A T Walden Spectral Analysis for Physical Applications Multitaper and Conventional UnivariateT echniques Cambridge Cambridge University Press 1993 6 226 pmtm 2 Thomson D J Spectrum estimation and harmonic analysis In Proceedings of the IEEE Vol 70 1982 Pgs 1055 1096 6 227 pmusic Purpose Syntax Description 6 228 Power spectrum estimate using MUSIC eigenvector method Pxx f pmusic x p Pxx f pmusic x p thresh Pxx f pmusic x p thresh nfft Fs window noverl ap Pxx f pmusic x corr Pxx f pmusic x ev Pxx f evects svals pmusic x pmusic estimates the power spectral density PSD of a signal or correlation matrix using Schmidt s eigen analysis method 1 The name MUSIC is an acronym for MUItiple SI gnal Classification The genvector method which uses eigenvalue weighting is also supported 2 The calling syntax is similar to that of psd which also performs spectrum estimation ps d uses the classical FFT based approach whilep music performs eigen analysis of the signal s correlation matrix Pxx f pmusic x p and Pxx f pmusic x p thresh returnPxx the power spectrum estimate and f a vector of frequencies at which the PSD is estimated x is the input signal where e A row or column vector represents one observation of the process output for example one
499. ultiplier Txy tfe x y nfft Fs window specifies a windowing function and the number of samples per section of thex vector If you supply a scalar for wi ndow Txy uses a Hanning window of that length The length of the window must be less than or equal tonf f t t f e zero pads the sections if the length of the window exceeds nf ft Txy tfe x y nfft Fs window noverlap overlaps the sections of x by noverl ap Samples You can use the empty matrix to specify the default value for any input argument except x or y For example Txy tfe x y f kaiser 128 5 uses 256 as the value for nf ft and 2 as the value for Fs Txy tfe x y dflag specifies a detrend option wheredf ag is e i near toremovethe best straight line fit from the prewindowed sections of x andy e mean to remove the mean from the prewindowed sections of x andy e none for no detrending default The df lag parameter must appear last in the list of input arguments t f e recognizes a df ag string no matter how many intermediate arguments are omitted tfe with no output arguments plots the magnitude of the transfer function estimate in decibels versus frequency in the current figure window tfe Example Compute and plot the transfer function estimate between two colored noise sequences x andy h firl 30 0 2 boxcar 31 X randn 16384 1 y filter h 1 x tfe x y 1024 512 Transfer Function Estimate 5 T T T T
500. um lag is N 1 c lags xcorr x y maxlags wherex andy arelengthN vectors returns the cross correlation sequence in a length 2 max ags 1 vector c l ags isa vector of the lag indices wherec was estimated that is maxl ags maxlags c lags xcorr x maxlags returnstheautocorrel ation sequence over the lag range maxlags maxlags c lags xcorr X maxlags wherex isan M by P matrix isa matrix with 2 max ags 1 rows whose P columns contain the cross correlation sequences for all combinations of the columns of X 6 325 xCcorr c lags xcorr x maxlags option and c lags xcorr x y maxlags option specifies both a maximum number of lags and a scaling option In all cases xcorr gives an output such that the zeroth lag of the correlation vector is in the middle of the sequence at element or row max ags 1 or atN Examples The second output ags is useful when plotting For example the estimated autocorrelation of zero mean Gaussian white noise Cyw m can be displayed for 10 lt m lt 10 using ww randn 1000 1 c_ww lags xcorr ww 10 coeff stem ags c_ww Swapping thex andy input arguments reverses and conjugates the output correlation sequence F or row vectors the resulting sequences are reversed left to right for column vectors up and down The following example illustrates this property mat 2st r is used for a compact display of complex numbers x 1 21 3 y 4 5 6
501. um relative error fi rls weights the error by 1 w 2 in nonzero amplitude bands in the d mode FIR Filter Design The magnitude response plots for the differentiators shown above are Differentiator odd order Differentiator even order 3500 3500 3000 3000 2500 2500 2000 2000 1500 1500 1000 1000 500 500 100 200 300 400 500 100 200 300 400 500 Frequency Normalized Frequency Normalized Constrained Least Squares FIR Filter Design The Constrained Least Squares CLS FIR filter design functions implement a technique that enables you to design FIR filters without explicitly defining the transition bands for the magnitude response The ability to omit the specification of transition bands is useful in several situations For example it may not be clear where a rigidly defined transition band should appear if noise and signal information appear together in the same frequency band Similarly it may make sense to omit the specification of transition bands if they appear only to control the results of Gibbs phenomena that appear in the filter s response See Selesnick Lang and Burrus 2 for discussion of this method Instead of defining passbands stopbands and transition regions the CLS method accepts a cutoff frequency for the highpass lowpass bandpass or bandstop cases or passband and stopband edges for multiband cases for the desired response In this way the CLS method defines t
502. ument This toolbox uses the convention that unit frequency is the Nyquist frequency defined as half the sampling frequency The normalized frequency therefore is always in the interval 0 lt f lt 1 For a system with a 1000 Hz sampling frequency 300 Hz is 300 500 0 6 To convert normalized frequency to angular frequency around the unit circle multiply by x To convert normalized frequency back to Hertz multiply by half the sample frequency Filter Requirements and Specification More rigorous filter requirements traditionally include passband ripple Rp in decibels stopband attenuation Rs in decibels and transition width Ws Wp in Hertz Magnitude 10 10 10 Frequency rad sec You can design Butterworth Chebyshev type I Chebyshev type ll and elliptic filters that meet this type of performance specification The toolbox order selection functions estimate the minimum filter order that meets a given set of requirements To meet specifications with more rigid constraints like linear phase or arbitrary filter shape use the FIR and direct IIR filter design routines 2 Filter Design IIR Filter Design 2 4 Theprimary advantage of IIR filters over FIR filters is that they typically meet a given set of specifications with a much lower filter order than a corresponding FIR filter Although IIR filters have nonlinear phase data processing within MATLAB is commonly performed off line t
503. unction estimate 3 14 unwrapping 1 27 6 317 Phase check box Filter Viewer 5 77 phase delay 1 28 6 165 defined 1 28 Index example 1 29 of linear response filter 2 18 phase demodulation 6 99 phase distortion eliminating during filtering 1 19 example 1 20 usingfiltfilt 1 20 in FIR filters 1 20 nonlinear in IIR filters 1 20 phase modification data dependent usingcceps 4 25 phase modulation 4 29 6 219 phase response 5 18 phase response plot 5 77 5 82 Phase Units pop up menu in Preferences dialog box 5 26 phase units in Filter Viewer 5 26 Play menu item Signal Browser 5 43 playing a signal 5 43 plot analog prototypes 2 12 coherence function 3 16 complex cepstrum 4 24 DFT 1 44 frequency response 1 25 magnitude 1 26 phase 1 26 group delay 1 29 5 77 5 84 impulse response 5 77 5 85 in Filter Viewer 5 74 5 76 5 78 5 80 magnitude response 5 68 5 77 5 80 modified periodogram 3 9 multitaper estimate 3 17 3 18 periodogram 3 7 phase delay 1 29 phase response 5 77 5 82 power spectral density 3 10 spectral density 5 92 step response 5 77 5 87 strip plot 6 304 tiling in Filter Viewer 5 79 transfer function 3 15 zero pole 1 30 5 77 5 85 6 341 plug ins 5 21 5 29 pm 4 29 p model See parametric modeling pmt m 3 6 6 6 6 224 example 3 17 pmusic 3 6 3 22 6 6 6 228 pole zero filter SeelIR filter pol y 1 33 1 42 pol y2rc 6 3 6 234 polynomial division 4 32 6 97 multiplication 6 69 roots 1 33 stabili
504. ures 1 2 Representing Signals 00 00 eee ees 1 4 Waveform Generation Time Vectors and Sinusoids 1 6 Working with Data 0 0 020 e eee 1 13 Filter Implementation and Analysis 1 14 filter Function Implementation and Initial Conditions 1 17 Other Functions for Filtering 1 19 Impulse Response 00 00 cee eee eee 1 23 Frequency Response 0 00 e eee eee eee 1 24 Zero Pole Analysis 0 60 cece eens 1 30 Linear System Models 0 000 ee eeeeee 1 32 Discrete Fourier Transform 2 0 5 1 43 References nmi oee i Be ee a Se heed 1 46 1 Signal Processing Basics Signal Processing Toolbox Central Features This chapter describes how to begin using MATLAB and the Signal Processing Toolbox for your signal processing applications It assumes a basic knowledge and understanding of signals and systems including such topics as filter and linear system theory and basic Fourier analysis There are many examples throughout the chapter that demonstrate how to apply toolbox functions If you are not already familiar with MATLAB s signal processing capabilities use this chapter in conjunction with the softwaretotry examples and learn about the powerful features available to you The Signal Processing Toolbox functions are algorithms expressed mostly in M files that implement a variety
505. urns ann point triangular window in the column vector w The coefficients of a triangular window are Forn odd 2k i lt pe tt n l 2 w k 2in k 1 aa n l 2 Forn even i 1 lt k lt n 2 w k AnH ee ee n 2 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 areequivalent tobartlett n bartlett Bartlett window blackman Blackman window boxcar Rectangular window chebwin Chebyshev window hammi ng Hamming window hanni ng Hanning window kaiser Kaiser window 1 Oppenheim A V and R W Schafer Discrete Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 6 315 tripuls Purpose Syntax Description See Also 6 316 Sampled aperiodic triangle generator y tripuls T tripuls T w y tripuls T w s 1 y tripuls T returns a continuous aperiodic symmetric unity height triangular pulse at the times indicated in array T centered about T 0 and with a default width of 1 y tripuls 7 w generates a triangle of width w y tripuls T w s generates a triangle with skews where 1 lt s lt 1 Whens isO asymmetric triangle is generated chirp Swept frequency cosine generator cos Cosine of vector matrix elements see the online MATLAB Function Reference diric Dirichlet or periodi
506. us domain to the discrete domain it maps the s plane into the z plane by H z H s 4271 zt Bilinear transformation maps the jQ axis of the continuous domain to the unit circle of the discrete domain according to 2 tan 2 k Thetoolbox function bi i near implements this operation wherethe frequency warping constant k is equal to twice the sampling frequency 2 Fs by default and equal to2 pi Fp tan pi Fp Fs ifyou givebi i near atrailing argument that represents a match frequency Fp If a match frequency Fp in Hertz is Special Topics in IIR Filter Design present bi i near maps the frequency Q 2nf in radians second tothe same frequency in the discrete domain normalized to the sampling rate 2zf fs also in radians second The bilinear function can perform this transformation on three different linear system representations zero pole gain transfer function and state space form Try calling bilinear with the state space matrices that describethe Chebyshev typel filter from the previous section using a sampling frequency of 2 Hz and retaining the lower band edge of 0 1 Hz Ad Bd Cd Dd bilinear At Bt Ct Dt 2 0 1 The frequency response of the resulting digital filter is bz az ss2tf Ad Bd Cd Dd convert to TF freqz bz az Magnitude Response dB rm a gt 3 s o o oN 4 J J fo J fi L ji fi fi i 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0
507. utoff frequency that allows el i p to achieve the given specifications Useellipord for lowpass highpass bandpass and bandstop filters For highpass filters Wp is greater than Ws For bandpass and bandstop filters Wp and Ws aretwo element vectors that specify the corner frequencies at both edges of the filter lower frequency edge first For the band filters el i pord returns Wn as atwo element row vector for input toe ip If filter specifications call for a bandpass or bandstop filter with unequal ripple in each of the passbands or stopbands design the filter as separate lowpass and highpass sections and cascade the two filters together 6 117 ellipord 6 118 Analog Domain n Wn ellipord Wp Ws Rp Rs s findstheminimumorder n and cutoff frequencies Wn for an analog filter In this casethe frequenciesin Wp andWs are in radians per second and may be greater than 1 Useel lipord for lowpass highpass bandpass and bandstop filters as described under Digital Domain ellipord Examples For 1000 Hz data design a lowpass filter with less than 3 dB of attenuation from 0 to 100 Hz and at least 15 dB of attenuation from 150 Hz tothe Nyquist frequency Wp 100 500 Ws 150 500 Rp 3 Rs 15 n Wn elli pord Wp Ws Rp Rs n Wn 0 2000 b a ellip n Rp Rs Wn freqz b a 512 1000 n 2 Elliptic Lowpass Filter T T F F De oO T D GS T i M
508. utton The mouse pointer becomes an arrow with a question mark symbol You can then click on any 5 57 5 Interactive Tools 5 58 object in the Filter Designer including menu items to find out what it is and how to use it General Controls Beneath the zoom controls are several general controls for filter design and display Algorithm Use the Algorithm pop up menu to select a design for the current filter When you select a design from the Algorithm pop up menu the magnitude response plot Specifications panel and Measurements panel all update to reflect the new design parameters Auto Design When the Auto Design check box is checked thefilter s magnitude response is redrawn whenever a filter specification is changed either by entering a valuein the Specifications panel or by dragging a specification line on the plot When the box is not checked the new response is computed and redrawn only when the Apply button is pressed or the specification lineis released Auto Design is initially off by default use the Filter Designer settings panel in the Preferences dialog to change this default setting See Filter Designer Settings on page 5 28 Sampling Frequency The Sampling Frequency field allows you to specify the filter s sampling frequency in Hertz To changethe sampling frequency typea value in the box and press Enter Return on Macintosh This is the same as changing the sampling frequency by selecting Samplin
509. ve PSD Analysis The Spectrum Viewer provides an interactive environment for the estimation of power spectral density for one data channel It allows you to view and modify spectra created in SPTool Using the Spectrum Viewer you can control the spectral computation parameters including FFT length window type and sampling frequency Using the Spectrum Viewer you can e View and compare spectral density plots e Use different estimation methods including Burg FFT MTM MUSIC Welch and Yule Walker AR e Modify spectrum parameters such as FFT length and window type For information on spectral analysis using tool box functions from the command line or from M files see Chapter 3 of this manual Opening the Spectrum Viewer You can open or activate the Spectrum Viewer from SPTool by pressing one of the following buttons Create View and Update See Creating a Spectrum on page 5 19 Viewing a Spectrum on page 5 20 and Updating a Spectrum on page 5 20 for complete details Here is a brief summary of each method of activating the Spectrum Viewer e Tocreate a spectrum select a signal in SPTool and press Create Press Apply in the Spectrum Viewer A default spectrum of the selected signal is generated and displayed You can view it in a variety of ways measure it and modify it in the Spectrum Viewer e Toview a spectrum select one or more spectra in SPTool and press View in the Spectra panel e Toupdate a sp
510. w one or more imported signals The Signal Browser provides tools for graphical analysis of the selected signal s Select one or more signals from the Signals list and click the View button in thesignal panel The Signal Browser displays the selected signal s See Using the Signal Browser Interactive Signal Analysis on page 5 42 for a full description of Signal Browser functions and operations Viewing a Filter Use the View button in the Filters panel to make the Filter Viewer active and view imported filters or filters designed edited in the Filter Designer The 5 17 5 Interactive Tools 5 18 Filter Viewer provides tools for analyzing filters you can investigate the magnitude response phase group delay zeros and poles and impulse and step responses of the selected filters Select one or more filters from the Filters list and click the View button in the filter panel The Filter Viewer displays the selected filters See Using the Filter Viewer Interactive Filter Analysis on page 5 74 for a full description of Filter Viewer functions and operations Designing a Filter New Design Use the Filter New Design button to make the Filter Designer active and design a filter The Filter Designer lets you create FIR and IIR digital filters of various lengths and types using the filter design functions in the Signal Processing Toolbox Click the New Design button in the Filter panel The Filter Designer displays a fi
511. wable deviation or ripples between the frequency response and the desired amplitude of the output filter for each band Useremez with the resulting order n frequency vector f o amplitude response vector ao and weights w to design the filter b which approximately meets the specifications given by remezord input parameters f a and dev b remez n fo ao w n fo a0 w remezord f a dev Fs specifies a sampling frequency Fs Fs defaults to 2 Hz implying a Nyquist frequency of 1 Hz You can therefore specify band edges scaled to a particular application s sampling frequency In some cases r emezor d underestimates the order n If the filter does not meet the specifications try a higher order such asSn 1 orn 2 c remezord f a dev Fs cell specifies acell array whose elements are the parameters toremez Design a minimum order lowpass filter with a 500 Hz passband cutoff frequency and 600 Hz stopband cutoff frequency with a sampling frequency of 6 263 remezord 2000 Hz at least 40 dB attenuation in the stopband and less than 3 dB of ripple in the passband rp 3 passband ripple rs 40 stopband ripple Fs 2000 sampling frequency f 500 600 cutoff frequencies a 1 0 desired amplitudes compute deviations dev 10 rp 20 1 10 rp 20 1 10 rs 20 n fo a0 w remezord f a dev Fs b remez n fo ao w h f freqz b 1 1024 Fs plot f 20 0g10 abs h Lowpass
512. windowed linear phase FIR digital filter design 1 It designs filters in standard lowpass bandpass highpass and bandpass configurations F or windowed filters with arbitrary frequency response usef i r2 b firl n Wn returns row vector b containing then 1 coefficients of an order n lowpass FIR filter This is a Hamming windowed linear phase filter with cutoff frequency Wn The output filter coefficients b are ordered in descending powers of z b z b b bn Wn the cutoff frequency is a number between 0 and 1 where 1 corresponds to half the sampling frequency the Nyquist frequency If Wn isatwo element vector Wn w1 w2 fir1 returns a bandpass filter with passbandwl lt lt w2 If Wn is a multi element vector Wn wl w2 w3 w4 w5 wn fir1 returns an order n multiband filter with bands 0 lt w lt wl wl lt w lt w2 wn lt W lt 1 By default the filter is scaled so that the center of the first passband has magnitude exactly 1 after windowing b firl n Wn ftype specifies a filter type whereft ype is e hi gh for a highpass filter with cutoff frequency Wn e stop for abandstop filter ifWn wl w2 The stopbandiswl lt lt w2 e DC 1 to make the first band of a multiband filter a passband e DC 0 to make thefirst band of a multiband filter a stopband 6 137 firl Algorithm 6 138 fir1 always uses an even filter order for the highpass and bandstop configurations
513. wing error message Argument list not in correct order If the second argument was entered as a scalar it is taken to bemax ag and no succeeding input can be a scalar When the second argument is a vector the first must also be a signal vector The third argument when present must be 6 327 xCcorr See Also References 6 328 a scalar or a string If they are not xcorr gives the appropriate error message s 3rd arg is maxlag 2nd arg cannot be scalar When b is a vector a must be a vector Maxlag must be a scalar Normally the lengths of the vector inputs should be the same if they are not then the only allowable scaling option is none If itis not xcorr gives the following error message OPTION must be none for different length vectors A and B conv Convolution and polynomial multiplication corrcoef Correlation coefficient matrix cov Covariance matrix xcorr2 Two dimensional cross correlation xcov Cross covariance function estimate equal to mean removed cross correlation 1 Bendat J S and A G Piersol Random Data Analysis and Measurenent Procedures New York J ohn Wiley amp Sons 1971 Pg 332 2 Oppenheim A V and R W Schafer Digital Signal Processing Englewood Cliffs NJ Prentice Hall 1975 Pgs 63 67 746 747 839 842 xcorr2 Purpose Syntax Description See Also Two dimensional cross correl ation C xcorr2 A C xcorr2 A B C xcorr2 A B re
514. wpass to bandstop analog filter transformation p2hp Lowpass to highpass analog filter transformation p2lp Lowpass to lowpass analog filter transformation 6 23 bilinear References 1 Parks T W and C S Burrus Digital Filte Design New York J ohn Wiley amp Sons 1987 Pgs 209 213 2 Oppenheim A V and R W Schafer Discr amp e Time Signal Processing Englewood Cliffs NJ Prentice Hall 1989 Pgs 415 430 6 24 blackman Purpose Syntax Description Algorithm Diagnostics Blackman window bl ackman n w bl ackman n sfl ag iT w blackman n returns then point symmetrically sampled Blackman window in the column vector w n should be a nonnegative integer The equation for a Blackman window is w k 0 42 0 5 cos 27 z1 0 08 cof 4 E k 1 n n n Blackman windows have slightly wider central lobes and less sideband leakage than equivalent length Hamming and Hanning windows w blackman n sflag returns ann point Blackman window using the window sampling specified by sf ag which can be either periodi c or symmetric the default When periodic is specified bl ackman computes a length n 1 window and returns the firstn points w 0 42 0 5 cos 2 pi 0 N 1 N 1 0 08 cos 4 pi 0 N 1 N 1 An error message is displayed when incorrect arguments are used Order cannot be less than zero Sampling must be either symmetric or periodic A warn
515. xin is a row otherwise it is a column vector 2 xin isan array andh isa vector There is one filter and many signals so the function convolves h with each column of xin Theresultingyout will be an array with the same number of columns as xi n 3 xin iSavector andh isan array Therearemany filters and onesignal sothe function convolves each column ofh with xi n Theresultingyout will bean array with the same number of columns ash 4 xin isan array andh isan array both with the same number of columns There are many filters and many signals so the function convolves corresponding columns of xin andh Theresultingyout isan array with the same number of columns as xi n andh If both p and q are equal to 1 that is there is no rate changing the result is ordinary convolution of two signals equivalent toconv yy upfirdn xx hh This example implements a seven channel filter bank by convolving seven different filters with one input signal then downsamples by five Assume that hh is an L by 7 array of filters yy upfirdn xx hh 1 5 6 319 upfirdn Algorithm Diagnostics 6 320 Implement a rate change from 44 1 kHz CD sampling rate to 48 kHz DAT rate a ratio of 160 147 This requires a lowpass filter with cutoff frequency at c 21 160 Design lowpass filter with cutoff at 1 160th of Fs hh firl 300 2 160 need a very long lowpass filter yy upfirdn xx hh 160 147 In this example
516. xisting filter in the same way Note that when Auto Design is disabled and you change a filter s parameter values the magnitude response plot changes from solid lines to dashed lines This indicates that the plot no longer reflects the current specifications When you press the Apply button the new response is computed and the lines revert to the solid style When Auto Design is enabled the plot updates whenever you change a filter specification NOTE You can only edit filters that were designed in SPTool 5 60 Using the Filter Designer Interactive Filter Design o r 12 Actual Fip 1507 Wimeght 1 Actual Fin 17 69 E i a i Filter Measurements Panel When you design a filter the Measurements panel Shown at left displays the values of filter parameters that do not appear in the Specifications panel F or example when the Filter Designer provides an Fs parameter in the Specifications panel it displays the Actual Fs value in the Measurements panel Similarly when the Minimum Order option is selected in the Specifications panel the computed filter order is displayed in the Order field of the Measurements panel The values in the Measurements panel are updated whenever the magnitude plot is redrawn Measurement Parameters Automatic Order Selection The parameter combinations that appear in the Measurements panel are shown in the following two tables The first table lists the parameters that appear when Minimum O
517. y 1 28 6 165 identification from frequency data 6 190 IIR 2 4 compared to FIR 2 4 implementation 1 14 6 127 6 130 FF T based FIR 6 127 overlap add method 1 22 using convolution 1 14 usingf ilter function 1 16 Index impulse response 1 14 1 23 6 179 initial conditions 1 17 linear system models 1 32 names 1 15 order 1 15 in state space representation 1 34 order estimation Butterworth 6 34 Chebyshev type 6 41 Chebyshev type I1 6 46 elliptic 6 117 equiripple FIR 6 263 phase delay 1 28 6 165 poles 1 30 1 33 representational models 1 32 representing in MATLAB 1 32 second order sections 1 37 specifications 2 7 startup transients 1 21 1 22 structure lattice 1 37 transposed direct form II 1 17 time domain representation 1 16 transfer function representation 1 15 two dimensional 6 133 zero phase 1 20 6 134 zeros 1 30 1 33 zeros and poles 1 33 Seealso FIR filter IIR filter digital filter design FIR 2 16 IIR 2 4 digital frequency xvii direct design 2 13 described 2 13 summary 2 5 diric 6 2 6 103 Dirichlet function 1 12 6 103 defined 1 12 example 1 12 discrete cosine transform DCT 6 92 applications 4 35 energy compaction property 4 36 example 4 36 inverse 4 35 6 173 reconstructing signal from few coefficients 4 36 discrete F ourier transform DFT 1 2 1 43 algorithms 1 45 and IIR filter implementation 1 22 and spectral analysis 3 6 applications 6 122 dependence on signal length 1 45 example 1 44 ex
518. y specifying the down flag Putting high Q sections at the beginning of the cascade by specifying the down flag reduces the sensitivity of the filter response to quantization noise near those poles Putting high Q sections at the end of the cascade the default prevents reduction in signal power level early in the cascade ss2sos orders all zero sections according tothe minimum of z and z SS2SOS where z i 1 2 are the zeros in the section References 1 and 2 provide a detailed discussion of section ordering 4 ss2sos scales the sections so the maximum of the magnitude of the transfer function of the first N sections in cascade is less than 1 max N i o aiea N 1 L 1 OEE i l subject to the constraint that the overall gain k stays the same L k a pe Ok This scalingis an attempt to minimize overflow in some standard fixed point implementations of filtering Diagnostics If thereis more than one input tothe system ss2s0s gives the following error message State space system must have only one input See Also cpl xpair Group complex numbers into complex conjugate pairs 0525 Second order section to state space conversion sos2tf Second order section to transfer function conversion 0S2zp Second order section to zero pole gain conversion 7p2sos Zero pole gain to second order section conversion References 1 Oppenheim A V and R W Schafer Discre teTime Signal Processing
519. z defines convergence as occurring when the invfreqz Example norm of the modified gradient vector is less thant ol tol isan optional parameter that defaults to 0 01 To obtain a weight vector of all ones use invfreqz h w nb na iter tol invfreqz h w nb na wt iter tol trace displays a textual progress report of the iteration invfreqz h w complex nb na creates a complex filter In this caseno symmetry is enforced and the frequency is specified in radians between r and T Convert a simple transfer function to frequency response data and then back to the original filter coefficients a 123 21 4 b 1 2 3 2 3 h w freqz b a 64 bb aa invfregz h w 4 5 bb 1 0000 2 0000 3 0000 2 0000 3 0000 aa 1 0000 2 0000 3 0000 2 0000 1 0000 4 0000 Notice that bb andaa are equivalent tob anda respectively However aa has poles outside the unit circle and thus the system is unstable Usei nvfreqz s iterative algorithm to find a stable approximation to the system bbb aaa invfreqz h w 4 5 30 bbb 0 2427 0 2788 0 0069 0 0971 0 1980 aaa 1 0000 0 8944 0 6954 0 9997 0 8933 0 6949 6 191 invfreqz Algorithm See Also References 6 192 By default i nvf r eqz uses an equation error method to identify the best model from the data This finds b anda in n min weak Awk Bow k b a KZI by creating a system of linear equations and solving them with MATLAB
520. zation 6 236 polyphase filtering techniques 1 19 polystab 6 9 6 236 power spectral density 6 239 approximating energy in frequency band 3 13 bias 3 11 computation parameters 5 93 5 94 confidence interval 3 14 default plot 5 93 defined 3 5 estimation by Burg method 3 6 3 20 5 95 estimation by FFT method 5 95 estimation by multitaper method 3 6 3 16 5 95 estimation by MUSIC method 3 6 3 22 5 96 estimation by Welch s method 3 6 3 10 5 97 1 19 Index 1 20 power spectral density cont estimation by Yule AR method 5 97 estimation by YuleWalker AR method 3 6 3 19 estimation methods 5 93 5 94 in SPTool 5 13 normalization 3 11 viewing in Spectrum Viewer 5 88 5 93 5 94 preferences rulers 5 22 saving in Signal Browser 5 43 preferences file in SPTool 5 30 sigprefs mat 5 30 Preferences menu item 5 7 5 21 5 29 prewarping 6 20 prolate spheroidal window 4 4 prony 2 5 4 10 4 12 6 8 6 237 Prony s method 4 12 6 237 modeling 4 12 prototype Bessel filter 2 11 6 15 Butterworth filter 2 8 6 28 Chebyshev type filter 6 40 Chebyshev type II filter 6 45 elliptic filter 6 116 psd 3 6 3 10 6 7 6 239 example 3 11 PSD See power spectral density ptm 4 29 pulse time demodulation 6 99 pulse time modulation 4 29 6 219 pulse train generator 6 244 pulse trains generating 1 10 pulstran 1 10 pulse width demodulation 6 99 pulse width modulation 4 29 6 219 pulstran 1 10 6 2 6 61 6 104 6 106 6 107 6 108
Download Pdf Manuals
Related Search
Related Contents
Bedienungsanleitung GL7-V manual Westinghouse 7812300 Use and Care Manual Sistema de transporte e elevação de cargas OPERATING INSTRUCTIONS FOR YOUR NEW WATFORD Tech Doc MS11MU 2011 0.0 1 barrage du canal de saint-ours remplacement Verbatim PinStripe USB Drive 4GB - Caribbean Blue Planmeca Compact Copyright © All rights reserved.
Failed to retrieve file