FFT of conjugate doesn't coincide exactly at the negative frequency

In summary: It didn't. I think their point was, if you draw the same plot twice, does it graphically show them slightly offset just to be helpful.In summary, the MATLAB code produces a one-pixel shift in the frequency domain spectrum when conjugating a signal. This shift is always present, no matter the size of the signal or the resolution of the graph.
  • #1
tworitdash
108
26
I am trying to understand why the conjugate of a signal in the time domain doesn't produce an exact flip of the frequency domain spectrum. There is always a one-pixel shift in the result.
image.png

The MATLAB code is shown below. I use a flip for the conjugate spectrum to show that it doesn't match the original spectrum and there is a delay of one resolution cell. I want to understand why this happens. It shouldn't as it is the perfect conjugate.

MATLAB code for fft of the conjugate:
 
Physics news on Phys.org
  • #2
Try comparing the numbers of the two curves to see if they are shifted too.

it could be a graph thing to show that there are two curves vs one curve completely overwriting the other curve.

One could also draw two sin or lines or parabolic curves and see if the graph exhibits the same one pixel shift.

upon resizing the graph is it the same one pixel shift?
 
  • Like
Likes tworitdash
  • #3
The code looks very compact to me .. :biggrin:

##\ ##
 
  • Like
Likes tworitdash
  • #4
jedishrfu said:
Try comparing the numbers of the two curves to see if they are shifted too.

it could be a graph thing to show that there are two curves vs one curve completely overwriting the other curve.

One could also draw two sin or lines or parabolic curves and see if the graph exhibits the same one pixel shift.

upon resizing the graph is it the same one pixel shift?
The graph has no issue at all. I have tested with Gaussian pulse in the frequency domain as well. It also has the same pixel shift. It is the issue of the conjugate. It shouldn't be like this. Probably something with the DC value which remains in the positive frequency always. I don't know. For simplicity, I used a monochromatic signal here. I usually do it with a Gaussian spectrum.
 
  • #5
BvU said:
The code looks very compact to me .. :biggrin:

##\ ##
Sorry! Now I can't edit the original post now. So, pasting the code here.
Matlab:
v_max = 7.5;
v = 5;
N = 128;
PRT = 1e-3;
lambda = 0.03;
vel_axis = linspace(-v_max, v_max, N);

x = exp(1j .* 4 .* pi .* v ./ lambda .* (1:N) .* PRT);

x_conj = conj(exp(1j .* 4 .* pi .* v ./ lambda .* (1:N) .* PRT));

x_fft = 1/sqrt(N) .* fftshift(fft(x, N));
x_conj_fft = 1/sqrt(N) .* fftshift(fft(x_conj, N));
figure; plot(vel_axis, db(abs(x_fft)), 'LineWidth', 2); hold on; plot(vel_axis, flip(db(abs(x_conj_fft))), 'LineWidth', 2);grid on;
the original post. So, I am pasting the code here.
 
Last edited by a moderator:
  • #6
The reason you couldn't edit your code is due to it not being pasted in the original post that's why @BvU commented on its compactness.

There is a time limit also that comes into play for post editing.
 
  • Like
Likes tworitdash
  • #7
Did you compare the data by printing it to see if it's identical?

Rounding error could be happening too.
 
  • Like
Likes tworitdash
  • #8
tworitdash said:
The graph has no issue at all. I have tested with Gaussian pulse in the frequency domain as well. It also has the same pixel shift. It is the issue of the conjugate. It shouldn't be like this. Probably something with the DC value which remains in the positive frequency always. I don't know. For simplicity, I used a monochromatic signal here. I usually do it with a Gaussian spectrum.

I think their point was, if you draw the same plot twice, does it graphically show them slightly offset just to be helpful.
 
  • Like
Likes tworitdash
  • #9
Office_Shredder said:
I think their point was, if you draw the same plot twice, does it graphically show them slightly offset just to be helpful.
Thank you for clarifying. No, if I use the same plot twice, they perfectly coincide with each other. There is no shift.
 
  • #10
jedishrfu said:
Did you compare the data by printing it to see if it's identical?

Rounding error could be happening too.
In the time domain yes, they both are perfect conjugate. However, after applying FFT to the original and to the conjugate, I see different values indeed.
 
  • #11
Perhaps this is something you could ask the MATLAB folks about As it seems it may be a subtle flaw in their computational library.

When I said compare the two curves, I meant a point by point comparison to see how significantly different they are. I don’t doubt you that they should be the same but computer math is limited in subtle ways.

If it were a constant x or y difference then you could look to see what is causing it. However, if the difference varies from point to point then that seems to be some other kind of computational issue.
 
  • Like
Likes tworitdash
  • #12
The problem is the combination of MATLAB's flip() and fftshift() functions.

After fftshift, the zero-frequency value is position 65 in the array indexed 1:128. After you flip, the zero-frequency is in position 64.
 
  • Like
  • Wow
Likes tworitdash, BvU and jedishrfu
  • #14
DrGreg said:
The problem is the combination of MATLAB's flip() and fftshift() functions.

After fftshift, the zero-frequency value is position 65 in the array indexed 1:128. After you flip, the zero-frequency is in position 64.
Thank you for the answer. My problem was indeed not the flip function. I just used flip to see if they coincide and it was indeed a bad choice as you pointed out.

However, my issue was more about the conjugate spectrum. Even without flip, you can see that both the spectra don't intersect each other exactly at 0. Screenshot attached. It is exactly one pixel after 0. That is why their peaks aren't exactly symmetric. You can see the values of abscissa at the peaks in the picture.

Screen Shot 2021-04-29 at 10.55.38 PM.png


I found the fix actually. I was so dumb to use the frequency (velocity) axis wrong for the fftshift. It didn't include the zero frequency point at all. Now I define the axis like this.

Axis for Doppler:
Axis = linspace(-N/2, N/2-1, N)/N;
vel_axis = 2 .* v_amb .* Axis;

Now, here you can see the modified one with this velocity axis. They cross each other now at 0 velocity point.

Screen Shot 2021-05-01 at 7.00.44 PM.png
 
  • Like
Likes BvU and DrGreg

FAQ: FFT of conjugate doesn't coincide exactly at the negative frequency

Why doesn't the FFT of a conjugate coincide exactly at the negative frequency?

The FFT (Fast Fourier Transform) is a mathematical algorithm used to convert a signal from its original domain (often a time series) to a representation in the frequency domain. In the frequency domain, the signal is decomposed into its component frequencies. The FFT algorithm assumes that the signal is periodic, meaning it repeats itself infinitely. However, when we take the FFT of a conjugate, we are essentially flipping the signal in time. This means that the signal is no longer periodic, resulting in a slight discrepancy at the negative frequency.

How significant is the discrepancy between the FFT of a conjugate and the negative frequency?

The discrepancy between the FFT of a conjugate and the negative frequency is usually very small and can be considered negligible in most cases. It is important to note that the FFT is an approximate algorithm and will never produce an exact representation of a signal in the frequency domain. The slight discrepancy at the negative frequency is a common occurrence and does not significantly affect the overall accuracy of the FFT.

Can the FFT of a conjugate be corrected to coincide exactly at the negative frequency?

While the FFT of a conjugate may not coincide exactly at the negative frequency, it is possible to correct this discrepancy by using a windowing function. A windowing function is a mathematical technique used to reduce the impact of non-periodic signal components on the FFT. By applying a windowing function, the FFT of a conjugate can be made to coincide exactly at the negative frequency.

Are there any situations where the FFT of a conjugate and the negative frequency do coincide?

In some cases, the FFT of a conjugate and the negative frequency may coincide perfectly. This is most likely to occur when the signal is periodic and symmetric. For example, a sinusoidal signal with a frequency of 1 Hz will have the same amplitude at the positive and negative frequencies. In this case, the FFT of the conjugate will coincide exactly at the negative frequency.

How does the FFT of a conjugate affect the interpretation of the frequency spectrum?

The FFT of a conjugate does not significantly affect the interpretation of the frequency spectrum. The slight discrepancy at the negative frequency is usually not noticeable and does not change the overall shape or characteristics of the spectrum. However, it is important to keep in mind that the FFT is an approximation and should not be used as the sole method for analyzing frequency spectra.

Similar threads

Replies
4
Views
3K
Replies
3
Views
2K
Replies
1
Views
4K
Replies
1
Views
1K
Replies
4
Views
5K
Replies
11
Views
3K
Replies
5
Views
3K
Back
Top