I need the code for Q5 plz 5. The Fast Fourier Transform is a version of the DFT
ID: 2250175 • Letter: I
Question
I need the code for Q5 plz
5. The Fast Fourier Transform is a version of the DFT which implements faster calculations when NO is a power of 2. Determine how much speed improvement is created A. Create a signal 1ike x in part (3) with a vector n of 1024 values. Run the fft of this signal 20 times and record the time elapsed. This can be accomplished by running the MATLAB “tic" command before the loop and “toc" command after the loop. B. Do the same as (a) above but with a vector with 1023 values C. What is the difference in the amount of time for the calculations? Note: Show the results of this calculation on command windowExplanation / Answer
clear all;
close all;
%=============Solution for 5(A)==============%
%-------Given the number of samples N=1024------%
N=1024;
n=0:N-1;
fL=5.5;
fs=8*fL;
Ts=1/fs;
x=cos(2*pi*fL*(n.*Ts));
tstart1=tic;
for i=1:20
X=fft(x);
end
tElapsed1=toc(tstart1);
display(['Time taken to complete fft 20 times when N is a power of 2=',num2str(tElapsed1)]);
%=============Solution for 5(B)==============%
%-------Given the number of samples N=1023------%
N=1023;
n=0:N-1;
fL=5.5;
fs=8*fL;
Ts=1/fs;
x=cos(2*pi*fL*(n.*Ts));
tstart2=tic;
for i=1:20
X=fft(x);
end
tElapsed2=toc(tstart2);
display(['Time taken to complete fft 20 times when N is not a power of 2=',num2str(tElapsed2)]);
%=============Solution for 5(c)=============%
diff_time=tElapsed2-tElapsed1;
display(['The difference between in the amount of time for calculations is ',num2str(diff_time),' (',num2str(diff_time/10e-6),'micro secs)']);
Output:
Time taken to complete fft 20 times when N is a power of 2=0.000581
Time taken to complete fft 20 times when N is not a power of 2=0.000937
The difference between in the amount of time for calculations is 0.000356 (35.6micro secs)