首页 > 其他 > 详细

《DSP using MATLAB》示例Example5.23

时间:2016-12-21 07:49:54      阅读:286      评论:0      收藏:0      [点我收藏+]

技术分享

代码:

conv_time = zeros(1,150); fft_time = zeros(1, 150);
%
% Nmax = 2048; 
for L = 1:150
	tc = 0; tf = 0;
	N = 2*L-1; nu = ceil(log10(N)/log10(2)); N = 2^nu;
	for I = 1:100
		h = randn(1,L); x = rand(1,L);
		t0 = clock; y1 = conv(h,x); t1 = etime(clock,t0); tc = tc + t1;
		t0 = clock; y2 = ifft(fft(h,N) .* fft(x,N)); t2 = etime(clock,t0);
		tf = tf + t2;
	end
	%
	conv_time(L)=tc/100; fft_time(L)=tf/100;
end

n=1:150;  

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Exameple5.23 ‘)
set(gcf,‘Color‘,‘white‘); 
plot(n(25:150), conv_time(25:150), n(25:150), fft_time(25:150));
xlabel(‘sequence length N‘); ylabel(‘Time in Sec.‘); title(‘comparison of convolution times‘);

  运行结果:

我的机子结果如下图:

技术分享

书中的例子,运行结果如下图:

技术分享

 

《DSP using MATLAB》示例Example5.23

原文:http://www.cnblogs.com/ky027wh-sx/p/6206230.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!