?? program_03_05.m
字號:
% 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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -