Inverse fourier transfer of cos function with time shift

6 ビュー (過去 30 日間)
Matt
Matt 2025 年 3 月 21 日
コメント済み: VBBV 2025 年 3 月 22 日
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?

採用された回答

TED MOSBY
TED MOSBY 2025 年 3 月 21 日
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 件のコメント
Matt
Matt 2025 年 3 月 21 日
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 2025 年 3 月 22 日
possibly due to the shift of the integration limits, from -pi to pi to 2*( 0 topi) in the transform.

サインインしてコメントする。

その他の回答 (1 件)

Paul
Paul 2025 年 3 月 22 日
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.

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by