📄 conv.sci
字号:
function c = conv(a, b)
//CONV Convolution and polynomial multiplication.
// C = CONV(A, B) convolves vectors A and B. The resulting
// vector is length LENGTH(A)+LENGTH(B)-1.
// If A and B are vectors of polynomial coefficients, convolving
// them is equivalent to multiplying the two polynomials.
//
// See also DECONV, CONV2, CONVN, FILTER and, in the Signal
// Copyright Aldo I Maalouf
na = length2(a);
nb = length2(b);
if na ~= prod(size(a)) | nb ~= prod(size(b))
error('A and B must be vectors.');
end
// Convolution, polynomial multiplication, and FIR digital
// filtering are all the same operations. Since FILTER
// is a fast built-in primitive, we'll use it for CONV.
// CONV(A,B) is the same as CONV(B,A), but we can make it go
// substantially faster if we swap arguments to make the first
// argument to filter the shorter of the two.
if na > nb
if nb > 1
a(na+nb-1) = 0;
end
c = mtlb_filter(b, 1, a);
else
if na > 1
b(na+nb-1) = 0;
end
c = mtlb_filter(a, 1, b);
end
endfunction
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -