CSD MATLAB Resources

May 24, 2019

MATLAB® offers operators supporting several statistical estimators using Welch’s method. These include the operation cpsd<…>:

cpsd(…)

Estimate cross power spectral density.

https://www.mathworks.com/help/signal/ref/cpsd.html

Example Code from MATLAB

clear                                      % clear all variables
format long g;                     % set format of text output
N = 16;                                  % length of input data sequence x
Fs = 1;                                  % sample rate (used for scaling)
percent = 50;                      % percent overlap
Nfft = N * (1-percent/100);
x= [0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0]’;
y= [0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0]’;
%   0        3          7              11  13  15
%—————————————————————————-
% smoothing window
%—————————————————————————-
window = hanning(Nfft);     % Hanning       window
%—————————————————————————-
% calculate estimates
%—————————————————————————-
[Sxy,freq]=cpsd(               x,y,window,Noverlap,Nfft,Fs);   % estimate Sxy
% |      |         |                     |  |  |                |              |       |_____sample rate
% |      |         |                     |  |  |                |              |________estimate length
% |      |         |                     |  |  |                |______________num. overlapping positions
% |      |         |                     |  |  |____________________ window type
% |      |         |                     | |______________________data sequence y
% |      |         |                     |_______________________data sequence x
% |      |         |_______________________________ estimation operation
% |     |____________________________________x-axis sequence
% |______________________________________ estimate sequence

References

Bendat, J.S. & Piersol, A.G. (2013). Engineering applications of correlation and spectral analysis. (2nd ed.). (pp. 511). Wiley.

Bendat, J.S. & Piersol, A.G. (2011). Random data: Analysis and measurement procedures. (4th ed.). (pp. 118). John Wiley and Sons.

Cadzow, J.A. (1987). Foundations of digital signal processing and data analysis. (pp. 336-341). Macmillan Publishing Company.

Carter, G.C. (1972). Estimation of the magnitude-squared coherence function (spectrum). (Report No. AD0743945). Naval Underwater Systems Center. https://apps.dtic.mil/dtic/tr/fulltext/u2/743945.pdf.

Clarkson, P.M. (1993). Optimal and adaptive signal processing. (1st ed.). Electronic Engineering Systems, Book 3. CRC Press.

Papoulis, A. (1984). Probability, random variables, and stochastic processes. (2nd ed.). McGraw-Hill.

Papoulis, A. (1991). Probability, random variables, and stochastic processes. (3rd ed.). McGraw-Hill.

Stoica, P. & Moses, R. (2005). Spectral analysis of signals. Prentice Hall.

Welch, P.D. (1967). The use of fast Fourier transform for the estimation of power spectra: A method based on time averaging over short, modified periodograms. IEEE Transactions on Audio and Electroacoustics, Au-15(2), 70-73. https://pdfs.semanticscholar.org/e633/45b4243e2376720a4e66373fdffe7a7d6be0.pdf.