Speeding up the computation

1 回表示 (過去 30 日間)
Uerm
Uerm 2020 年 1 月 24 日
回答済み: Gaurav Garg 2020 年 1 月 29 日
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 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 1 月 25 日
try profiling to see which part of your code is taking the longest.

サインインしてコメントする。

回答 (1 件)

Gaurav Garg
Gaurav Garg 2020 年 1 月 29 日
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.

カテゴリ

Help Center および File ExchangeSignal Analysis についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by