📄 convolve.m
字号:
function z = convolve (x,y)
%-----------------------------------------------------------------------
% Usage: z = convolve (x,y)
%
% Description: Compute the convolution of two discrete-time signals.
%
% Inputs: x = n by 1 vector containing samples of first signal
% y = m by 1 vector containing samples of second signal
% with m <= n. If m < n, y is padded with n-m zeros.
%
% Outputs: z = n by 1 vector containing convolution of x with y.
%-----------------------------------------------------------------------
chkvec (x,1,'convolve');
chkvec (y,2,'convolve');
n = length(x);
m = length(y);
if m > n
disp ('Argument 2 of convolve can not be longer than argument 1');
return
end;
% Compute DFTs of x(k) and y(k), pad y with (n-m) zeros
Y = zeros(n,1);
Y(1:m) = y;
X = dft (x,1);
Y = dft (Y,1);
% Compute inverse DFT of X(m)Y(m)
X = X .* Y;
z = real(dft (X,-1));
%-----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -