?? 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 + -