Confusion regarding plot of Linear convolution vs high speed convolution?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am reading proakis book,Digital signal processing using Matlab, 3rd edition I am performing example 5.23 but i am not getting same plot/results as book although i am using almost same code
First i am attaching my code and output and then i will attach snapshot of book containing code and output The issue with book code is that , i get error for "nu" variable and matlab says "NI" is undefined(i have underlined NI in book snapshot with red paint pencil) , so i used "NL" in my code and "NL"=N*L ,but i am not getting output as book
My code is as follow
clc;clear all;close all;
conv_time = zeros(1,150); fft_time = zeros(1,150);
%
for L = 1:150
tc = 0; tf=0;
N = 2*L-1; nu = ceil(log10(N*L)/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; subplot(1,1,1);
plot(n(25:150),conv_time(25:150),n(25:150),fft_time(25:150))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/318375/image.jpeg)
Above is plot generated by my code
below is snap of plot and code of book
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/318378/image.jpeg)
댓글 수: 0
채택된 답변
Vinay Ingle
2020년 6월 18일
Hello,
There is a typo (given in the errata sheet). The correct line is
nu = ceil(log10(N)/log10(2));
But even with this correction, you will not get the correct plot in Figure 5.22. This is because that plot was obtained in MS-DOS operating system using MATLAB-386 (version 3.7g) which ran in a single user and single program environment. Furthermore, MATLAB since then made several internal changes to how it is run (for efficiency purposes) and now it uses FFTW library for FFT computations. All these changes make comparisons of timimg computations meaningless and irrelevent, especially if you use today's computers. Figures 5.21 and 5-22 are for educational purposes only. If you want to reproduce those figures, you will need a 33 MHz 486 computer running MATLAB 3.7g.
댓글 수: 2
Vinay Ingle
2020년 7월 14일
This is not a MATLAB question. Please send such questions outside of this forum.
추가 답변 (1개)
Karthik Malisetty
2020년 6월 18일
Hi,
From my understanding, the line
nu = ceil(log10(NI)/log10(2));
from the book seems to be using NI as a constant, while in your code, you are using the product of N and L (loop variable).
So, this might be causing the difference in the output. Recheck your NI value from the book (or any other sources).
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!