Practical Signal Processing Concepts and Algorithms using MATLAB
Practical Signal Processing Concepts and Algorithms using MATLAB. Spectral Analysis of Signals. Section Outline. Signal statistics Discrete Fourier transform Power spectral density estimation Time-varying spectra. Statistical Signal Processing. time. time. ensemble. System. time.
Practical Signal Processing Concepts and Algorithms using MATLAB
E N D
Presentation Transcript
Practical Signal Processing Concepts and Algorithms using MATLAB Spectral Analysis of Signals
Section Outline • Signal statistics • Discrete Fourier transform • Power spectral density estimation • Time-varying spectra
Statistical Signal Processing time time ensemble System time
Example: Crosscorrelation y x >> [c,lags] = xcorr(x,y) >> stem(lags,c)
Correlation and Covariance The functions xcorr and xcov estimate the cross-correlation and cross-covariance sequences of random processes. The cross-correlation sequence is a statistical quantity defined as where xn and yn are stationary random processes, , and E{·} is the expected value operator which measures the similarity between the two waveforms.The covariance sequence is the mean-removed cross-correlation sequence ,
or, in terms of the cross-correlation, • Example on xcorr • >> y = x; • >> x = [1 1 1 1 1]'; • >> xyc = xcorr(x,y) • >> stem(xyc) • Example on xcov >>ww = randn(1000,1); % Generate uniform noise with %mean = 1/2. >> [cov_ww,lags] = xcov(ww,10,'coeff'); >> stem(lags,cov_ww)
Discrete Fourier Transform (DFT) Discrete Fourier Transform: Complex nth roots of unity Signal y (top) and transform Y (bottom)
Fast Fourier Transform (FFT) FFT y Pad / Chop Efficient DFT Y Buffer Y = fft(y,n) Window length length(y) FFT length n fast
Fast Fourier Transform (FFT) • The discrete Fourier transform, or DFT, is the primary tool of digital signal processing. • The foundation of the Signal Processing Toolbox is the fast 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.
Cont. t = (0:0.001:1); %0.001 is sampling x = sin(2*pi*50*t) + 2*sin(2*pi*120*t); y = fft(x); %Compute DFT of x m = abs(y); %magnitude f = (0:length(y)/2-1)*1000/length(y); %Frequency vector plot(f,m(1:1:(length(m)-1)/2)) %before filter grid [b,a] = butter(9,100/500,'high'); %design filter c=filter(b,a,x); %implement filter figure(2) y = fft(c); %Compute DFT of c(filtered x) m = abs(y); % Magnitude f = (0:length(y)/2-1)*1000/length(y); %Frequency vector plot(f,m(1:1:(length(m)-1)/2)) %after filter Grid
Spectral Analysis with the FFT ySampled signal FsSamples/unit time n = length(y)Number of samples t = (0:n-1)/Fs Principal range dt = 1/FsTime increment Y = fft(y)DFT of sampled signal abs(Y)Amplitude of DFT abs(Y).^2/length(Y)Power of DFT f = (0:n-1)*(Fs/n)Frequency (cycles/unit time) (n/2)*(Fs/n) = Fs/2Nyquist frequency p = 1./fPeriod (unit time/cycle)
FFT Example >> Fs = 100; >> t = 0:1/Fs:10-1/Fs; >> y = sin(2*pi*15*t) + sin(2*pi*30*t); >> Y = fft(y,512); >> f = (0:length(Y)-1)*(Fs-1)/length(Y); >> Power = Y.*conj(Y)/length(Y); >> plot(f,Power) >> title('Periodogram') Symmetric about Fs/2 = 50 Use fftshift to center at 0
FFT Demos >> sigdemo1 >> playshow fftdemo >> phone >> playshow sunspots
Aliasing Revisited Original signal Spectral copy 5 Hz sine wave sampled at 15 Hz 5 Hz sine wave sampled at 7.5 Hz +Fs +Fs -Fs -Fs Principal range Principal range No overlap/aliasing Overlap/aliasing
Power Spectral Density (PSD) Ryy( f ) Total signal power of analog signal y = Ryy( f ) is the DFT of the autocorrelation functionryy(t) Estimate PSD from a finite sample Nonparametric Parametric Subspace Welch pwelch Multitaper pmtm Burg pburg Yule-Walker pyulear EV peig MUSIC pmusic
Periodogram >> [Pxx,w] = periodogram(x) Welch >> [Pxx,w] = pwelch(x) Multitaper >> [Pxx,w] = pmtm(x,nw) Nonparametric Methods
Parametric Methods • Yule-Walker AR Method • >> [Pxx,f] = pyulear(x,p,nfft,fs) • Burg Method • >> [Pxx,f] = pburg(x,p,nfft,fs) • Covariance and Modified Covariance Methods • >> [Pxx,f] = pcov(x,p,nfft,fs) • >> [Pxx,f] = pmcov(x,p,nfft,fs) Order of AR model
Subspace Methods • Eigenvector Method • >> [S,f] = peig(x,p,nfft,fs) • Multiple Signal Classification (MUSIC) Method • >> [S,f] = pmusic(x,p,nfft,fs)
Spectrum Viewer in SPTool 1. Select signal in Signal Viewer in SPTool. 2. Select Create Spectra Spectrum Viewer. Analysis method Display window
Time-Varying Spectra >> [B,f,t] = specgram(x,nfft,fs,window,numoverlap)
Spectrogram Demos >> specgramdemo >> xpsound
Example: Reduced Sampling Rate >> HAL9000