Recently I'm spending my time implementing some patients' analysis using Mathematica Classify function. But I need to rewrite some MATLAB functions for computing input parameters.

There is a problem, that I haven't found an alternative for pmtm function.

In short:
Is there any way how to rewrite this code in Mathematica?

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

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

1. Link to pmtm function is http://www.mathworks.com/help/signal/ref/pmtm.html
2. [pxx,f] = pmtm(x,nw,f,fs) returns the two-sided multitaper PSD estimates at the frequencies specified in the vector, f. The vector, f, must contain at least 2 elements. The frequencies in f are in cycles per unit time. The sampling frequency, fs, is the number of samples per unit time. If the unit of time is seconds, then f is in cycles/sec (Hz).

  • 3
    $\begingroup$ If you use MATLink, then it is as simple as pmtm = MFunction["pmtm", "OutputArguments" -> 2] after you initialize the package. You'd call it as {p, f} = pmtm[data, tapers, n, fs]. $\endgroup$ – rm -rf Jan 7 '15 at 15:47
  • $\begingroup$ Now I'm using MATLink, but I need to convert it to C++ / C# .dll in another phase of my project. And MATLAB Coder doesn't support pmtm function, but inMathematica I can use CCodeGeneration. $\endgroup$ – Zdeněk Tesař Jan 7 '15 at 16:08
  • $\begingroup$ We can't help with C++/C# conversion either. You can look at the source code by typing edit pmtm. That should give you hints to proceed with your translation attempts. $\endgroup$ – rm -rf Jan 7 '15 at 16:10
  • 2
    $\begingroup$ Mathematica code will not be per se easily convertible to C, only a very limited function subset will support direct compilation. $\endgroup$ – Yves Klett Jan 7 '15 at 16:24
  • 1
    $\begingroup$ @OleksandrR. To me it looks like the OP just asks wether there is a simple equivalent of this function in Mathematica. We have had and answered questions like that before. $\endgroup$ – Sjoerd C. de Vries Jan 8 '15 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.