I am trying to speed up the code below. Are there any suggestions on how I could make it faster? Thanks!
%A=ones(192,64); %example matrix
%B=ones(192,64); %example matrix
Bpad=padarray(B,[11 11],0,'both');
c=zeros(1,529);
jcount=1;
for i=-11:11
for j=-11:11
c(jcount)=sum(sum(A.*conj(Bpad(12+i:end-11+i,12+j:end-11+j))));
jcount=jcount+1;
end
end

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2012 年 4 月 13 日

1 投票

c0 = conv2(B,A);
c = reshape(c0(2:end-1,2:end-1)',1,[]);
OR
c0 = conv2(Bpad,A,'valid');
c = reshape(c0',1,[]);

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2012 年 4 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by