example4_6.m

来自「原名:数字信号处理基础及MATLAB实现,解压缩密码:lfjk2002@163.」· M 代码 · 共 20 行

M
20
字号
%example4_6
conv_time=zeros(1,150);fft_time=zeros(1,150);N=10;
for L=1:150
    tc=0;tf=0;N=L;
    NI=2*N-1;nu=ceil(log10(NI)/log10(2));LI=2.^nu;
    for I=1:200
        h=randn(1,LI);
        x=rand(1,LI);
        t0=clock;y1=conv(h,x);t1=etime(clock,t0);
        tc=tc+t1;
        t0=clock;y2=ifft(fft(h,LI).*fft(x,LI));t2=etime(clock,t0);
        tf=tf+t2;
    end
    conv_time(L)=tc/100;
    fft_time(L)=tf/100;
end
n=1:150;subplot(1,1,1);
plot(n(25:150),conv_time(25:150),'K+-',n(25:150),fft_time(25:150),'K-')
legend('卷积','高速卷积')
xlabel('N');ylabel('执行时间');

⌨️ 快捷键说明

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