Magnitude-squared coherence
Cxy = mscohere(x,y)
Cxy = mscohere(x,y,window)
Cxy = mscohere(x,y,window,noverlap)
[Cxy,W] = mscohere(x,y,window,noverlap,nfft)
[Cxy,F] = mscohere(x,y,window,noverlap,nfft,fs)
[Cxy,F] = mscohere(x,y,window,noverlap,f,fs)
[...] = mscohere(x,y,...,'twosided')
mscohere(...)
Cxy = mscohere(x,y)
finds
the magnitude-squared coherence estimate, Cxy
,
of the input signals, x
and y
,
using Welch's averaged modified periodogram method.
The input signals may be either vectors or two-dimensional matrices.
If both are vectors, they must have the same length. If both are matrices,
they must have the same size, and mscohere
operates
columnwise: Cxy(:,n) = mscohere(x(:,n),y(:,n))
.
If one is a matrix and the other is a vector, then the vector is converted
to a column vector and internally expanded so both inputs have the
same number of columns.
For real x
and y
, mscohere
returns
a one-sided coherence estimate. For complex x
or y
,
it returns a two-sided estimate.
mscohere
uses the following default values:
Parameter | Description | Default Value |
---|---|---|
| FFT length which determines the frequencies at which the coherence is estimated For real If | Maximum of 256 or the next power of 2 greater than the
length of each section of |
| Sampling frequency | 1 |
| Windowing function and number of samples to use for each section | Periodic Hamming window of sufficient length to obtain
eight equal sections of x and |
| Number of samples by which the sections overlap | Value to obtain 50% overlap |
Note
You can use the empty matrix, |
Cxy = mscohere(x,y,window)
specifies
a windowing function, divides x
and y
into
equal overlapping sections of the specified window length, and windows
each section using the specified window function. If you supply a
scalar for window
, then Cxy
uses
a Hamming window of that length.
Cxy = mscohere(x,y,window,noverlap)
overlaps
the sections of x
by noverlap
samples. noverlap
must
be an integer smaller than the length of window
.
[Cxy,W] = mscohere(x,y,window,noverlap,nfft)
uses
the specified FFT length nfft
to calculate the
coherence estimate. It also returns W
, which is
the vector of normalized frequencies (in rad/sample) at which the
coherence is estimated. For real x
and y
, Cxy
length
is (nfft
/2 + 1)
if nfft
is even; if nfft
is
odd, the length is (nfft
+ 1)/2. For complex x
or y
,
the length of Cxy
is nfft
. For
real signals, the range of W
is [0, π]
when nfft
is even and [0, π)
when nfft
is odd. For complex signals, the range
of W
is [0, 2π).
[Cxy,F] = mscohere(x,y,window,noverlap,nfft,fs)
returns Cxy
as
a function of frequency and a vector F
of frequencies
at which the coherence is estimated. fs
is the
sampling frequency in Hz. For real signals, the range of F
is
[0, fs
/2] when nfft
is
even and [0, fs
/2) when nfft
is
odd. For complex signals, the range of F
is [0, fs
).
[Cxy,F] = mscohere(x,y,window,noverlap,f,fs)
computes
the coherence estimate at the frequencies f
. f
is
a vector containing two or more elements.
[...] = mscohere(x,y,...,'twosided')
returns
a coherence estimate with frequencies that range over the whole Nyquist
interval. Specifying 'onesided'
uses half the Nyquist
interval.
mscohere(...)
plots the
magnitude-squared coherence versus frequency in the current figure
window.
Note If you estimate the magnitude-squared coherence with a single window, or section, the value is identically 1 for all frequencies [1]. You must use at least two sections. |
[1] Stoica, Petre, and Randolph Moses. Spectral Analysis of Signals. Upper Saddle River, NJ: Prentice Hall, 2005.
[2] Kay, Steven M. Modern Spectral Estimation. Englewood Cliffs, NJ: Prentice-Hall, 1988.
[3] Rabiner, Lawrence R., and Bernard Gold. Theory and Application of Digital Signal Processing. Englewood Cliffs, NJ: Prentice-Hall, 1975.
[4] Welch, Peter D. "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. Vol. AU-15, 1967, pp. 70–73.
cpsd
| periodogram
| pwelch
| tfestimate