필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to vectorize this code? element wise to save time

조회 수: 1 (최근 30일)
MIDO
MIDO 2020년 4월 19일
마감: MATLAB Answer Bot 2021년 8월 20일
% size(matAL) > 32,500,5
matCT=zeros(500,32,32); %Pre-allocate
x=0;
for t=1:500
x=1+x;
for i=1:32
for j=1:32
xsd = squeeze(matAL(i,t,:) .* conj(matAL(j,t,:)));
matCT(x,j,i) = abs(mean(exp(1i*angle(xsd))));
end
end
end

답변 (1개)

Vimal Rathod
Vimal Rathod 2020년 4월 26일
Hi,
As all the three for loops have some dependencies it is difficult to vectorize the code.
you can try the following code, it is partially vectorized.
for i = 1:32
for j = 1:32
xsd = squeeze(matAL(i,1:500,:) .* conj(matAL(j,1:500,:)));
matCT(1:500,j,i) = abs(mean(exp(1i*angle(xsd(1:500,:)))'));
end
end

이 질문은 마감되었습니다.

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by