user3991298
user3991298

Reputation:

How to rewrite MATLAB pmtm in Mathematica or C#

How can I rewrite MATLAB pmtm function in Mathematica or C# (.NET 4.0)?

I am using pmtm in this way:

[p,f] = pmtm(data,tapers,n,fs);

Alternatively written without pmtm using spectrum.mtm and psd.

Hs = spectrum.mtm(tapers,'adapt');
powerspectrum = psd(Hs,data,'Fs',fs,'NFFT',n);
p = powerspectrum.data;
f = powerspectrum.Frequencies;

Where data is a column vector with 2048 elements, fs = 40, tapers = 8 and n = 2^nextpow2(size(data,1)) = 2048;

Thanks.

Upvotes: 0

Views: 207

Answers (1)

Margus
Margus

Reputation: 20048

The pmtm (multitaper method) is a non-parametric method for computing a power spectrum similar to the periodogram approach.

In this method a power spectrum is computed by windowing the data and computing a Fourier transform, taking the magnitude of the result and squaring it. The multitaper method averages a pre-determined number of periodograms each computed with a different window. This method works because the selected windows have two mathematical properties. First, the windows are orthogonal. This means that each one of the periodograms is uncorrelated so averaging multiple periodograms gives an estimate with a lower variance than using just one taper. Second, the windows have the best possible concentration in the frequency domain for a fixed signal length. This means that these windows perform the best possible with respect to leakage.

Mathematica has package for time series that contains funtions like PowerSpectralDensity.

If you have further problems ask your question in https://mathematica.stackexchange.com/

Upvotes: 1

Related Questions