Inverse fourier transfer of cos function with time shift

6 vues (au cours des 30 derniers jours)
Matt
Matt le 21 Mar 2025
Commenté : VBBV le 22 Mar 2025
Hi there,
I'm creating a fourier transfer of a simple cos function with a time shift of pi, and then trying to invert it. For some reason, the graph of the inversion has a much smaller amplitude although the magnitude and phase look ok. Here's what I've tried:
dt = .001;
t = 0:dt:50;
x1 = cos(4*pi*t);
Wmax = 2*pi*20;
K = 2000;
w = (0:K-1) * Wmax / K;
X1 = x1 * exp(-j * t' * w) * dt;
Y1 = x1 * exp(-j * t' * (w-pi)) * dt;
y1 = 1/(2*pi) * Y1 * exp(j * w' * t) *dt;
mag_X1 = 2 * abs(X1);
phase_X1 = angle(X1);
mag_Y = 2 * abs(Y1);
phase_Y = angle(Y1);
subplot(3,2,1);
plot(t, x1);
xlabel('time');
ylabel('x(t)');
axis([0 5 -1.5 1.5]);
title('time domain');
grid on;
subplot(3,2,2);
plot(t, y1);
Warning: Imaginary parts of complex X and/or Y arguments ignored.
xlabel('time');
ylabel('y(t)');
axis([0 5 -1.5 1.5]);
title('time domain');
grid on;
Not sure what's going on? Can somebody please help?

Réponse acceptée

TED MOSBY
TED MOSBY le 21 Mar 2025
Hi Matt,
In the inverse transform you are still multiplying by 'dt' instead of the frequency increment 'dω'.
In your code, you have:
y1 = 1/(2*pi) * Y1 * exp(j * w' * t) * dt;
which uses 'dt' as the integration step for frequency. You should replace 'dt' with the frequency‐domain step size:
dw = w(2) - w(1); % Frequency increment
Then in the inverse transform do
y1 = 1/(2*pi) * Y1 * exp(1j * w' * t) * dw;
Also, since the reconstructed signal should be real, calling 'real' in the plot avoids the warning “Imaginary parts of complex X and/or Y arguments ignored.” :
plot(t, real(y1));
Hope this helps!
  2 commentaires
Matt
Matt le 21 Mar 2025
Hey ted,
That really helped a lot, but I had to change the dw value to 2*w(2), to get the graph to come out right, not sure why.
Thanks very much.
VBBV
VBBV le 22 Mar 2025
possibly due to the shift of the integration limits, from -pi to pi to 2*( 0 topi) in the transform.

Connectez-vous pour commenter.

Plus de réponses (1)

Paul
Paul le 22 Mar 2025
Hi Matt,
Keep in mind that you are inherently dealing with a windowed cosine, x1(t) = cos(4*pi*t)*w(t), where w(t) = 1 for 0 <= t <= 50 and 0 otherwise.
a) The Fourier transform of that windowed cosine has significant content at negative frequencies, but X1 is only computed for positive frequencies.
b) Is Y1 supposed to be the Fourier transform of y1(t) = x1(t-pi)? If so, I don't believe that's the correct expression for Y1.
c) because of (a), essentially half of Y1 is missing (the portion due to negative frequencies) so y1 won't be correct. In addition, as pointed out by @TED MOSBY, the variable of integration for y1 is w, so the sum should be multiplied by dw.

Produits


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by