如题所述
第1个回答 2011-06-30
用matlab中con函数求卷积
nction coresult = xcorr_my(A,B)
% XCORR_MY 自编相关函数
% copyright @lskyp 2009
% 2009.05.11
length1 = length(A);
length2 = length(B);
if length1 ~= length2
if length1本回答被提问者采纳
nction coresult = xcorr_my(A,B)
% XCORR_MY 自编相关函数
% copyright @lskyp 2009
% 2009.05.11
length1 = length(A);
length2 = length(B);
if length1 ~= length2
if length1本回答被提问者采纳
第2个回答 2011-06-30
function coresult = xcorr_my(A,B)
% XCORR_MY 自编相关函数
% copyright @lskyp 2009
% 2009.05.11
length1 = length(A);
length2 = length(B);
if length1 ~= length2
if length1 > length2
B = [B zeros(1,length1-length2)];
else
A = [A zeros(1,length2-length1)];
end
end
N = length(A);
coresult = zeros(1,2*N-1);
for k = 1:N
temp = A*B(k);
end
for k = 1:N
temp = [zeros(1,2*N-1-k+1-N) temp zeros(1,k-1)];
end
for k = 1:N
coresult = coresult+temp;
end
给分吧
% XCORR_MY 自编相关函数
% copyright @lskyp 2009
% 2009.05.11
length1 = length(A);
length2 = length(B);
if length1 ~= length2
if length1 > length2
B = [B zeros(1,length1-length2)];
else
A = [A zeros(1,length2-length1)];
end
end
N = length(A);
coresult = zeros(1,2*N-1);
for k = 1:N
temp = A*B(k);
end
for k = 1:N
temp = [zeros(1,2*N-1-k+1-N) temp zeros(1,k-1)];
end
for k = 1:N
coresult = coresult+temp;
end
给分吧