program_03_05.m
来自「自编的一些小波源程序,用MATLAB编的.希望对那些喜欢小波的人有所帮助.去解压」· M 代码 · 共 29 行
M
29 行
% Program 3_5
% Linear Convolution Via the DFT
%
% Read in the two sequences
colordef black;
x = input('Type in the first sequence = ');
h = input('Type in the second sequence = ');
% Determine the length of the result of convolution
L = length(x)+length(h)-1;
% Compute the DFTs by zero-padding
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:1:L-1;
subplot(2,1,1)
stem(k,y1,'g')
xlabel('Time index n');ylabel('Amplitude');
title('Result of DFT-based linear convolution')
y2 = conv(x,h);
error = y1-y2;
subplot(2,1,2)
stem(k,abs(error),'g')
xlabel('Time index n');ylabel('Amplitude')
title('Magnitude of error sequence')
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?