why fft of an even and real signal in time domain gives imaginary part?
44 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
2NOR_Kh
am 2 Dez. 2022
Kommentiert: 2NOR_Kh
am 3 Dez. 2022
This is the question:
a. Create a real and even-symmetric signal for use as a test signal. Since this is easiest to do when the length is odd, take N to be odd (e.g., N = 21). Verify that the DFT of this signal is purely real, and that it is also even-symmetric.
This is my attempt:
I have a coine function which is real and even and I expecy its fourier transform to be real and conjugate symmetry. I applied f1=fftshift(abs(fft(x1))); for taking the fft and the imaginary part is zero. But for part b it asks:
b. Now take the FFT of the same signal, but with the length three times the original (i.e., N = 63). Verify that the transform is no longer purely real (unless, of course, your test signal were the impulse).
still with the same procedure the imaginary part is zero. Where did I make a mistake?
This is my code for a:
N = 21;
tmin=-1;
tmax=1;
t = linspace(tmin,tmax,N+1);
t(end) = [] ;
fs=1/abs(t(1)-t(2));
a = 2;
x1 = cos(a*pi*t);
figure,plot(t,x1);xlabel 'x axis', ylabel 'y axis', title 'cos(2*pi*t)'
k = ( (-(N-1)/2) : ((N-1)/2) )/N*fs;
f1=fftshift(abs(fft(x1)));
figure,plot(k,f1);xlabel 'x axis', ylabel 'y axis',
title 'fourier transform of cos(2*pi*t)'
figure,plot(k,imag(f1)),
title 'imaginary part of the fourier transform of cos(2*pi*t)'
xlabel 'x axis', ylabel 'y axis'
code for part b:
%% the same signal with three times more points
N2 = 63;
tmin=-1;
tmax=1;
t2 = linspace(tmin,tmax,N2+1);
t2(end) = [] ;
fs2=1/abs(t2(1)-t2(2));
a = 2;
x2 = cos(a*pi*t2);
figure,plot(t2,x2);xlabel 'x axis', ylabel 'y axis', title 'cos(2*pi*t)'
k2 = ( (-(N2-1)/2) : ((N2-1)/2) )/N2*fs2;
f2=fftshift(abs(fft(x2)));
figure,plot(k2,f2);xlabel 'x axis', ylabel 'y axis',
title 'fourier transform of cos(2*pi*t)'
figure,plot(k2,imag(f2)),
title 'imaginary part of the fourier transform of cos(2*pi*t)'
xlabel 'x axis', ylabel 'y axis';
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 2 Dez. 2022
t = linspace(tmin,tmax,N+1);
t(end) = [] ;
Your signal must not return to origin in the final sample. You need a signal such that repmat of the signal would be multiple periods. For example if the signal was triangle 0 1 then if you input 0 1 0 then fft treats it as if it were an indefinite chain of 0 1 0 0 1 0 0 1 0 rather than as 0 1 0 1 0 1...
Also if you are going to use that k then you need to fftshift to plot properly. The negative frequencies are after the positive.
9 Kommentare
Walter Roberson
am 3 Dez. 2022
fft of "the same signal" "with length 63" is probably fft(x1, 63) rather than creating a new signal of length 63
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Discrete Fourier and Cosine Transforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!