用matlab中con函数求卷积

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/02 23:34:06

用matlab中con函数求卷积
用matlab中con函数求卷积

用matlab中con函数求卷积
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
给分吧