用matlab中con函数求卷积

上海清纯玉女 1年前 已收到1个回答 举报

美丽的湖 幼苗

共回答了19个问题采纳率:84.2% 举报

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
给分吧

1年前

8
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.016 s. - webmaster@yulucn.com