Signal Processing Toolbox Help Desk

cohere

Purpose

Estimate magnitude squared coherence function between two signals.

Syntax

Description

Cxy = cohere(x,y) finds the magnitude squared coherence between length n signal vectors x and y. The coherence is a function of the power spectra of x and y and the cross spectrum of x and y:

x and y must be the same length. Cxy = cohere(x,y) uses the following default values:

nfft specifies the FFT length that cohere uses. This value determines the frequencies at which the coherence is estimated. Fs is a scalar that specifies the sampling frequency. window specifies a windowing function and the number of samples cohere uses in its sectioning of the x and y vectors. noverlap is the 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.

If x is real, cohere estimates the coherence function at positive frequencies only; in this case, the output Cxy is a column vector of length nfft/2 + 1 for nfft even and (nfft + 1)/2 for n odd. If x or y is complex, cohere estimates the coherence function at both positive and negative frequencies, and Cxy has length nfft.

Cxy = cohere(x,y,nfft) uses the FFT length nfft in estimating the power spectrum for x. Specify nfft 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 as Cxy, so plot(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 and y. 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 to nfft; cohere zero pads the sections if the window length exceeds nfft.

Cxy = cohere(x,y,nfft,Fs,window,noverlap) overlaps the sections of x by noverlap samples.

You can use the empty matrix [] to specify the default value for any input argument except x or y. For example,

uses 256 as the value for nfft and 2 as the value for Fs.

Cxy = cohere(x,y,...,'dflag') specifies a detrend option, where dflag is

The dflag parameter must appear last in the list of input arguments. cohere recognizes a dflag 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.

Example

Compute and plot the coherence estimate between two colored noise sequences x and y:

Diagnostics

An appropriate diagnostic messages is displayed when incorrect arguments are used:

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 and y into overlapping sections, detrends each section, and multiplies each section by window.
  2. It calculates the length nfft fast Fourier transform of each section.
  3. It averages the squares of the spectra of the x sections to form Pxx, averages the squares of the spectra of the y sections to form Pyy, and averages the products of the spectra of the x and y sections to form Pxy. It calculates Cxy by

See Also

csd

Estimate the cross spectral density (CSD) of two signals.

psd

Estimate the power spectral density (PSD) of a signal.

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 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 (June 1967). Pgs. 70-73.



[ Previous | Help Desk | Next ]