# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# wcoher

(Not recommended) Wavelet coherence

`wcoher` in not recommended. Use `wcoherence` instead.

## Syntax

```WCOH = wcoher(Sig1,Sig2,Scales,wname)WCOH = wcoher(...,Name,Value)[WCOH,WCS] = wcoher(...)[WCOH,WCS,CWT_S1,CWT_S2] = wcoher(...)[...] = wcoh(...,'plot')```

## Description

`WCOH = wcoher(Sig1,Sig2,Scales,wname)` returns the wavelet coherence for the input signals `Sig1` and `Sig2` using the wavelet specified in `wname` at the scales in `Scales`. The input signals must be real-valued and equal in length.

`WCOH = wcoher(...,Name,Value)` returns the wavelet coherence with additional options specified by one or more `Name,Value` pair arguments.

```[WCOH,WCS] = wcoher(...)``` returns the wavelet cross spectrum.

```[WCOH,WCS,CWT_S1,CWT_S2] = wcoher(...)``` returns the continuous wavelet transforms of `Sig1` and `Sig2`.

`[...] = wcoh(...,'plot')` displays the modulus and phase of the wavelet cross spectrum.

## Input Arguments

 `Sig1` A real-valued one-dimensional input signal. `Sig1` is a row or column vector. `Sig2` A real-valued one-dimensional input signal. `Sig2` is a row or column vector. `Scales` `Scales` is a vector of real-valued, positive scales at which to compute the wavelet coherence. `wname` Wavelet used in the wavelet coherence. `wname` is any valid wavelet name.

### Name-Value Pair Arguments

 `'asc'` Scale factor for arrows in quiver plot. `wcoher` represents the phase using `quiver`. `asc` corresponds to the `scale` input argument in `quiver`. Default: 1 `'nas'` Number of arrows in scale. Together with the number of scales, `nas` determines the spacing between the `y` coordinates in the input to `quiver`. The `y` input to `quiver` is `1:length(Scales)/(nas-1):Scales(end)` Default: 20 `'nsw'` Length of smoothing window in scale. `nsw` is a positive integer that specifies the length of a moving average filter in scale. Default: 1 `'ntw'` Length of smoothing window in time. `ntw` is a positive integer that specifies the length of a moving average filter in time. Default: `min[20,0.05*length(Sig1)]` `'plot'` Type of plot. `plot` is one of the following character vectors: `'cwt'`Displays the continuous wavelet transforms of signals 1 and 2.`'wcs'`Displays the wavelet cross spectrum.`'wcoh'`Displays the phase of the wavelet cross spectrum. `'all'`Displays all plots in separate figures.

## Output Arguments

 `WCOH` Wavelet coherence. `WCS` Wavelet cross spectrum. `CWT_S1` Continuous wavelet transform of signal 1. `CWT_S2` Continuous wavelet transform of signal 2.

## Examples

Wavelet coherence of sine waves in noise with delay:

```t = linspace(0,1,2048); x = sin(16*pi*t)+0.5*randn(1,2048); y = sin(16*pi*t+pi/4)+0.5*randn(1,2048); wname = 'cgau3'; scales = 1:512; ntw = 21; % smoothing parameter % Display the modulus and phased of the wavelet cross spectrum. wcoher(x,y,scales,wname,'ntw',ntw,'plot'); ```

Sine wave and Doppler signal:

```t = linspace(0,1,1024); x = -sin(8*pi*t) + 0.4*randn(1,1024); x = x/max(abs(x)); y = wnoise('doppler',10); wname = 'cgau3'; scales = 1:512; ntw = 21; % smoothing parameter % Display of the CWT of the two signals. wcoher(x,y,scales,wname,'ntw',ntw,'plot','cwt'); % Display of the wavelet cross spectrum. wcoher(x,y,scales,wname,'ntw',ntw,'nsw',1,'plot','wcs'); % Display of the modulus and phased of the wavelet cross spectrum. wcoher(x,y,scales,wname,'ntw',ntw,'plot'); ```

collapse all

### Wavelet Cross Spectrum

The wavelet cross spectrum of two time series, x and y is:

`${C}_{xy}\left(a,b\right)=S\left({C}_{x}^{*}\left(a,b\right){C}_{y}\left(a,b\right)\right)$`

where Cx(a,b) and Cy(a,b) denote the continuous wavelet transforms of x and y at scales a and positions b. The superscript * is the complex conjugate and S is a smoothing operator in time and scale.

For real-valued time series, the wavelet cross spectrum is real-valued if you use a real-valued analyzing wavelet, and complex-valued if you use a complex-valued analyzing wavelet.

### Wavelet Coherence

The wavelet coherence of two time series x and y is:

`$\frac{{|S\left({C}_{x}^{*}\left(a,b\right){C}_{y}\left(a,b\right)\right)|}^{2}}{S\left(|{C}_{x}\left(a,b\right){|}^{2}S\left(|{C}_{y}\left(a,b\right){|}^{2}}$`

where Cx(a,b) and Cy(a,b) denote the continuous wavelet transforms of x and y at scales a and positions b. The superscript * is the complex conjugate and S is a smoothing operator in time and scale.

For real-valued time series, the wavelet coherence is real-valued if you use a real-valued analyzing wavelet, and complex-valued if you use a complex-valued analyzing wavelet.

## References

Grinsted, A, J.C. Moore, and S. Jevrejeva. "Application of the cross wavelet transform and wavelet coherence to geophysical time series. Nonlinear Processes in Geophysics. 11, 2004, pp. 561-566.

Torrence. C., and G. Compo. "A Practical Guide to Wavelet Analysis". Bulletin of the American Meteorological Society, 79, pp. 61-78.