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 CenterFile Exchange에서 Signal Analysis에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by