How to parallelize this code or make it more efficient
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm doing 3D fft and I would like to parallelize this code if possible, or at least make it more efficient.
Dim=size(y);
N1_FFT=2*2^nextpow2(Dim(1));
N2_FFT=2*2^nextpow2(Dim(2));
N3_FFT=2*2^nextpow2(Dim(3));
N_FFT=[N1_FFT,N2_FFT,N3_FFT];
%Calculate 3D fft
CostFunction3=y;
for p = 1:length(size(y))
CostFunction3 = fft(CostFunction3,N_FFT(p),p);
end
CostFunction3 = fftshift(abs(CostFunction3).^2);
Edit: forgot to mention, y is a 3D matrix with signal samples
2 Kommentare
Adam
am 8 Feb. 2017
If y is a vector how is this a 3D FFT?
Also you should use
ndims(y)
if you want to loop over the number of dimensions, which is what length( size(y) ) will give you, but in your case, if y is a vector this will return 2 which is not helpful really anyway because one of those dimensions will be a singleton.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!