PSD (Welch method - spectrum averaging).

Namespace: dsp::fourier

Prototype

tuple<Vecf, Vecf> psd_welch(const Veccf &x, int N, cstring fen="hn")

Parameters

xSignal to be analyzed.
NDimension of each window (that is, the resulting PSD resolution), in number of samples.
fenType of windowing ("hn", "hm", "re", ...).

Returns

A tuple with two elements: frequences vectors (normalized, between -0.5 and 0.5), and the spectrum.

Description

This function estimates the PSD using the spectrum averaging method: several PSD are computed using windowed parts of the signal (optionnaly with some overlap), then averaged.

Exemple

  soit n = 8 * 1024;
  soit x = sigexp(0.02, n) + 0.1 * randn(n);
  soit [fr1, S1] = psd(x);
  soit [fr2, S2] = psd_welch(x, 1024);
  soit [fr3, S3] = psd_welch(x, 256);

  Figures f;
  f.subplot().plot(x);
  f.gcf().titres("Signal");
  f.subplot().plot(fr1, S1);
  f.gcf().titres("PSD - sans moyennage", "Frequence (Hz)", "Magnitude (dB)");
  f.subplot().plot(fr2, S2);
  f.gcf().titres("PSD - moyennage par blocs de 1024 pts", "Frequence (Hz)", "Magnitude (dB)");
  f.subplot().plot(fr3, S3);
  f.gcf().titres("PSD - moyennage par blocs de 256 pts", "Frequence (Hz)", "Magnitude (dB)");

PSD and averaging

See also

psd(), psd_subspace()