Speeding up the computation

1 Ansicht (letzte 30 Tage)
Uerm
Uerm am 24 Jan. 2020
Beantwortet: Gaurav Garg am 29 Jan. 2020
Hi, I have run the following code, which takes ages to complete. Even when I use high performance computers, after several days, the computation has still not completed. Is there any way, I can speed up the computation? Maybe by writing it another way? The code is here:
max_wavelet_level = 8;
nn = 5;
for i = 1:length(Data)
i
patient = tensor{1,i};
for k = 1:size(patient,1)
for j = 1:size(patient,3)
WDEC{1,i}(k,:,:,j) = single(modwt(tensor{1,i}(k,:,j),max_wavelet_level,'db4'));
for l =1:max_wavelet_level+1
[imf,res] = emd(squeeze(WDEC{1,i}(k,l,:,j)),'Display',0);
pad_size = max(0,nn-size(imf,2));
pad = zeros(size(imf,1),pad_size);
padded_imf = cat(2,imf,pad);
EMD{1,i}(k,l,:,:,j) = single(padded_imf(:,1:nn));
end
end
end
end
I am running discrete wavelet transform on my signal. Subsequently, I run the EMD algorithm on the subsignals.
  1 Kommentar
Mohammad Sami
Mohammad Sami am 25 Jan. 2020
try profiling to see which part of your code is taking the longest.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Gaurav Garg
Gaurav Garg am 29 Jan. 2020
Hi,
You can use parfor loop to run your for loop on multiple workers.
However, parfor can only be used when there aren’t any dependencies between different wokers/threads which seems to be true in your case. Moreover, parfor loops cannot be nested (parfor cannot be placed inside another parfor).
So, you can consider running parfor on either the first loop (parfor i = 1:length(Data)), or any other loop which should run fine too.

Kategorien

Mehr zu Continuous Wavelet Transforms finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by