1
$\begingroup$

I am trying to find the frequency difference ($\Delta f= f_1 - f_2$) between two complex sinusoidal signals using Matlab. The two signals are: $$r_1 (t)= A~ e^{j 2 \pi f_1 t}= A \cos(2 \pi f_1 t)+j A\sin(2 \pi f_1 t)$$ $$r_2 (t)= A~ e^{j 2 \pi f_2 t}= A \cos(2 \pi f_2 t)+j A\sin(2 \pi f_2 t)$$ where $f_1=150\, \text{KHz}$ and $f_2=400\, \text{KHz}$

In my Matlab code, I considered the signals are sampled at $F_s=900 \, \text{KHz}$ then

    A=1;
    j=sqrt(-1);
    f_1=150e3;
    f_2=400e3;
    Fs=900e3;    
    n=0:1/Fs:1-1/Fs;
    r1s= A*cos(2*pi*f_1*n)+1j*A*sin(2*pi*f_1*n);
    r2s= A*cos(2*pi*f_2*n)+1j*A*sin(2*pi*f_2*n);

Then, to find $\Delta f$, I multiplied both signals as follows:

     z= r1s.*conj(r2s);
     Fz=fft(z);
     subplot(2,1,1)
     plot(real(Fz));
     subplot(2,1,2)
     plot(imag(Fz));

Then, I applied $\text{FFT}$ and plotted the real and imaginary part of the multiplication. But I could not find the pulse at $f_1 - f_2$. The pulse was at high frequency.

Also, I multiplied the two signals as

     z2= r1s.*r2s;
     Fz2=fft(z2);
     subplot(2,1,1)
     plot(real(Fz2));
     subplot(2,1,2)
     plot(imag(Fz2));

and applied $\text{FFT}$. The pulse was at $f_1 + f_2$, which means that what I am doing makes sense.

My question is why could I not get the frequency difference when I applied the multiplication with complex conjugate?

$\endgroup$
5
  • $\begingroup$ Please post code that actually runs. I've edited it adding multiply operators, but you still need to define A, f_1, f_2 and Fs. Pasted code should run "as-is" $\endgroup$
    – Jdip
    Oct 25, 2022 at 23:10
  • $\begingroup$ I have a feeling I know what's going on here... Could you post the code that you are using for the fft? $\endgroup$
    – user58975
    Oct 26, 2022 at 5:02
  • $\begingroup$ @Jdip , I already defined defined the variables. The code does not have any problem and it works perfectly. I just included part of it for simplicity. @djg135, I used the matlab fft function fft(z) to do the FFT. $\endgroup$ Oct 26, 2022 at 10:04
  • 1
    $\begingroup$ You get a peak at $f_1-f_2 = -250 kHz$ which wraps around to 650 kHz . If you want $f_2-f_1$ you need to use z= r2s.*conj(r1s); $\endgroup$
    – Hilmar
    Oct 26, 2022 at 13:05
  • $\begingroup$ @Hilmar Thank you sir!! It works. $\endgroup$ Oct 26, 2022 at 13:32

1 Answer 1

1
$\begingroup$

In the first case you're multiplying $$r_1(t) \times r_2(t) = e^{j\omega_1 t}e^{j\omega_2 t}$$ so in the frequency domain, you're convolving: $$R_1(\omega) \,\circledast \,R_2(\omega) = 2\pi\delta(\omega-\omega_1)\,\circledast\,2\pi\delta(\omega-\omega_2)$$ which gives you a value at $\omega_1 + \omega_2$. In terms of frequency, that's $150 + 400 = 550\, \text{kHz}$


The Fourier transform of the conjugate is the conjugate of the frequency reversed Fourier Transform: $$r_2(t) \xrightarrow{} R_2(\omega)\\ r_2^{*}(t) \xrightarrow{} R_2^{*}(-\omega)$$ Note that because the Fourier Transform of a complex exponential is real, $R_2(\omega)$ is real, so $$R_2^{*}(-\omega) = R_2(-\omega) = 2\pi\delta((2\pi - \omega) - \omega_2)$$

The point is that $R_2$ is reversed, which in the frequency domain gives you a value at $\omega = 2\pi - \omega_2$.


With that in mind, in the second case you're multiplying $$r_1(t) \times r_2^{*}(t) = e^{j\omega_1 t}e^{-j\omega_2 t}$$ so in the frequency domain, you're convolving: $$R_1(\omega) \,\circledast \,R_2(-\omega) = 2\pi\delta(\omega-\omega_1)\,\circledast\,2\pi\delta((2\pi-\omega)-\omega_2)$$ which gives you a value in the spectrum at $\omega = \omega_1 + 2\pi - \omega_2$.

In terms of frequency, that's $150 + 900 - 400 = 650\, \text{kHz}$

$\endgroup$
3
  • $\begingroup$ Yes, @Jdip. I got a pulse at $650kHz$ as you described in the last section. To get $f_1 − f_2$ , I did multiply r2s.*conj(r1s) as @Hilmar suggested. $\endgroup$ Oct 26, 2022 at 13:33
  • $\begingroup$ @wesamamiri That's to get $f_2 - f_1$ actually, but yes, in that case that's $\omega_2 + 2\pi - \omega_1 = 400 + 900 - 150 = 1150 \, \text{Hz}$, which wraps around to $250 \, \text{Hz}$ Glad I could help, hopefully you understand better why what's happening is happening. Please accept the answer if you're satisfied so others know it's been resolved ;) $\endgroup$
    – Jdip
    Oct 26, 2022 at 15:41
  • $\begingroup$ Thanks for your help! I do care about the absolute value of the frequency difference (drift). So, $f_1 - f_2$ will be the same as $f_2 - f_1$ for my case. I did accept your answer. $\endgroup$ Oct 26, 2022 at 15:49

Your Answer

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

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