matlab算信号卷积(不用conv) 怎样用matlab求卷积
matlab算信号卷积(不用conv)
function c = conv_new(a, b)
na = length(a)
nb = length(b)
if na ~= numel(a) || nb ~= numel(b)
error(MATLAB:conv:AorBNotVector, A and B must be vectors.)
end
if na > nb
if nb > a(na nb-1) = 0
end
c = filter(b, 1, a)
else
if na > b(na nb-1) = 0
end
c = filter(a, 1, b)
end
怎样用matlab求卷积
如果你要的是符号卷积那就没有直接的功能函数要自己写出卷积表达式,再用符号积分函数去积,经常积不出如果是数值积分(序列)有conv这一族函数(help里面有相关函数那些)其实你要卷积还不如直接去算F变换再去求反变换来的方便
用matlab中con函数求卷积
function coresult = xcorr_my(A,B)
% XCORR_MY 自编相关函数
% copyright @lskyp 200% 2009.05.1length1 = length(A)
length2 = length(B)
if length1 ~= length if length1 > length 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
给分吧