How to parallelize this code or make it more efficient
24 次查看(过去 30 天)
显示 更早的评论
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 个评论
Adam
2017-2-8
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!