Question

I have a dataset Sig of size 65536 x 192 in Matlab. If I want to take the one-dimensional fft along the second dimension, I could either do a for loop:

%pre-allocate ect..
for i=1:65536
   F(i,:) = fft(Sig(i,:));
end

or I could specify the dimension and do it without the for loop:

F = fft(Sig,[],2);

which is about 20 times faster for my dataset.

I have looked for something similar for the discrete wavelet transform (dwt), but been unable to find it. So I was wondering if anyone knows a way to do dwt across a specified dimension in Matlab? Or do I have to use for loops?

Was it helpful?

Solution

I presume you're using the function from the Wavelet Toolbox: http://www.mathworks.co.uk/help/toolbox/wavelet/ref/dwt.html

The documentation doesn't seem to describe acting on an array, so it's probably not supported. If it does allow you to input an array, then it will operate on the first non-singleton dimension or it will ignore the shape and treat it as a vector.

OTHER TIPS

In your loop FFT example, it seems you operate on lines. Matlab use a Column-major order. It may explain the difference of performance. Is the performance the same if you operate on columns ? If this is the right explanation, you could use dwt in a loop.

A solution if you really need performance is to do your own MEX calling a C discrete wavelet transform library the way you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top