conv_dft.m

来自「经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助」· M 代码 · 共 18 行

M
18
字号
% Name:conv_dft
% Linear convolution Via the DFT
x=input ('Type in the first sequence = ');
h=input ('Type in the second sequenc = ');
% Determine the length of the result of convolution
L=length(x)+length(h)-1;
XE=fft(x,L);
HE=fft(h,L);
% Determine the IDFT of the product
y1=ifft(XE.*HE);
% Plot the sequence generated by DFT-based convolution
% and the error from direct linear convolution
k=0:L-1;
subplot(211),stem(k,y1),xlabel('Time index n'),ylabel('Amplitude')
title('Result of DFT-based linear convolution')
y2=conv(x,h);error=y1-y2;
subplot(212),stem(k,abs(error)),xlabel('Time index n'),ylabel('Amplitude')
title('Magnitude of error sequence')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?