📄 convfft.m
字号:
%利用FFT计算两个有限长序列的线性卷积
%并用传统计算法计算卷积,比较两种方法的速度
L=5000;
N=L*2-1;
n=0:(L-1);
x1=0.5*n;
x2=2*n;
%Compute convotion x1 * x2 using function CONV in traditional way
t0=clock;
yc=conv(x1,x2);
tc=etime(clock,t0)
%Compute convotion x1 * x2 using FFT
%Principle:product in time region equals convotion in frequency
t0=clock;
yf=ifft(fft(x1,N).*fft(x2,N));
tf=etime(clock,t0)
n1=0:length(yf)-1;
plot(n1,yc,'r',n1,abs(yf),'b')
%Conclusion:
% 1. the results from both computing methods are same
% 2. computing convotion using FFT is much faster than that using CONV
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -