2
$\begingroup$

I am currently working on simulating RF transmissions for beamforming and other applications in Matlab.

One of the fundamental properties that I need to simulate is signal propagation delay due to transmission distance. This can either be done by generating the signal $s(t-\tau)$ with offset $\tau = d / c$ where $c$ is the speed of light and $d$ the transmission distance, or by utilising the Fourier transform property $s(t-\tau) = \mathcal{F}^{-1}(\mathcal{F}(s(t)) \exp(-j2\pi f\tau))$ after the fact.

However, the Fourier transform method produces complex time domain signals in practice. I wanted to confirm whether the imaginary component produced in this instance is a result of insufficient computational precision, or if the imaginary component has some interpretation as an IQ signal (and if so, how to interpret this IQ data given that there's no carrier involved in this process).

Below is a minimum working example in Matlab to demonstrate.

N = 100; % number of data points
t = linspace(0, 2*pi, N+1); t(end) = []; % time vector
dt = t(2) - t(1); % time delta
s = cos(5*t) + cos(3*t) + cos(t); % some baseband signal

fs = 1 / dt; % sample rate
f = linspace(-fs/2, fs/2, N+1); f(end) = []; % frequency vector

tau = 0.5*dt; % chosen delay (fractional sample)

s_delayed = ifft(ifftshift(fftshift(fft(s)) .* exp(-1j*2*pi*f*tau))); % delay in fourier domain

% plot original and delayed signal
figure, plot(t, s)
hold on, plot(t, real(s_delayed));
plot(t, imag(s_delayed));
legend('original', 'real of time delayed', 'imag of time delayed')
$\endgroup$
2
  • $\begingroup$ This SO answer (stackoverflow.com/questions/7743769/…) bears on python calculations, but address your problem as well: ` Observe that the discrete Fourier transform is rather different from the continuous Fourier transform. For a densely sampled function there is a relation between the two, but the relation also involves phase factors and scaling in addition to fftshift. ` $\endgroup$
    – V.V.T
    May 27, 2022 at 5:11
  • 1
    $\begingroup$ The key here is the distinguish between the discrete and the continuous domain. The time shifting properties are quite a bit different between the two $\endgroup$
    – Hilmar
    May 27, 2022 at 13:03

1 Answer 1

3
$\begingroup$

It is nothing about the numerical precision in your case, the main reason is the fractional delay. We know that phase shift of DFT corresponds to a circular shift in time domain. The DFT of $x[n]$ is $$ X[k] = \sum_{n=0}^{N-1} x[n] e^{-j2\pi kn/N} $$

and its time delayed signal $x[n-D]$ has a DFT $$ \begin{aligned} \text{DFT}\{x[n-D]\} &= \sum_{n=0}^{N-1} x[n-D] e^{-j2\pi kn/N} \\ &=\sum_{m=0}^{N-1} x[m] e^{-j2\pi km/N} e^{-j2\pi kD/N} \\ &= X[k] e^{-j2\pi kD/N} \end{aligned} $$

For any real-valued sequence $x[n]$ we have the following facts:

  • $X[0]$ is real, and equals to $\sum_n x[n]$
  • $X[N/2]$ is real if $N$ is even, and equals to $\sum_n (-1)^n x[n]$

Apparently $x[n-D]$ is a real sequence and should follows the above properties. Let's check it out:

  • $X[0] e^{-j2\pi 0 D/N} = X[0]$ is real
  • $X[N/2] e^{-j2\pi (N/2) D/N} = X[N/2] e^{-j\pi D}$ is a real number only if $D$ is an integer. So if you want a fractional delay $D$, you won't get a real-valued IDFT result.

Here's a modified matlab code. Check the value of S(1), S(51), phaseshift(1), phaseshift(51, S_delayed(1), S_delayed(51) when you change delay D. You may notice that s_delayed has very small imaginary parts even if an integer delay is chosen, that is because of the computational precision. In this case you can use ifft(Y, 'symmetric') to force the output to be real.

N = 100; % number of data points
t = linspace(0, 2*pi, N+1).'; t(end) = []; % time vector
dt = t(2) - t(1); % time delta
s = cos(5*t) + cos(3*t) + cos(t); % some baseband signal

k = (0:N-1).';

D = 5; % chosen delay
phaseshift = exp(-1j*2*pi*k*D/N);
S = (fft(s));
S_delayed = S .* phaseshift;
s_delayed = ifft((S_delayed)); % delay in fourier domain

% plot original and delayed signal
figure, plot(t, s)
hold on, plot(t, real(s_delayed));
plot(t, imag(s_delayed));
legend('original', 'real of time delayed', 'imag of time delayed')
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.