Normally I compute the spectrum of a signal using pmtm:
signal = rand(1000,1);
NW = 4;
Fr = 1:50;
Fs = 200;
[p, fr] = pmtm( signal, NW, Fr, Fs);
However I'm looking for a way to vectorize this so I can compute multiple spectra at the same time. I tried:
signal = rand(1000,10); %<--- notice I have 10 columns instead of 1
NW = 4;
Fr = 1:50;
Fs = 200;
[p, fr] = pmtm( signal, NW, Fr, Fs);
but it produces an error that doesn't really tell me what I did wrong. I know I can wrap the call to pmtm
in a loop.
Here is the error:
Error using .* Matrix dimensions must agree.
Error in pmtm>mtm_spectrum (line 231) [Xx,w] = computeDFT(E(:,1:k).*x(:,ones(1,k)),nfft,Fs);
Error in pmtm (line 142) [S,k,w] = mtm_spectrum(x,params);
This leads me to suspect that there isn't a vectorized way to achieve what I want. I was hoping that someone here would know how to do this.