## time delay ---- frequency shift Fourier property

Started by 7 years ago●11 replies●latest reply 7 years ago●552 viewsHello everyone,

I am trying to remove a phase shift in frequency domain. I simulate a signal (cosine) and I add time delay in it and I try to reverse it in frequency domain. I do it as follows:

Fs = 800;

Time_max = 4; % seconds

t = 0:(1/Fs):Time_max-1/Fs;

delay = pi/3;

f = 5; %Hz

y=exp(1i*2*pi*f*t.^2);

y=real(y);

y1=exp(1i*2*pi*f*(t+pi/3).^2);

y1=real(y1);

SIZE = (length(y));

Y = fft(y,SIZE);

Y2=fft(y1,SIZE);

df = Fs/SIZE;

f1=[(0:1:SIZE/2-1)*df ((SIZE/2:SIZE-1)-SIZE)*df];

for k = 1:SIZE

L(k) = Y2(k)*exp(-(1i*2*pi*f1(k)*delay));

end

yd = real(ifft(L));

In the case that I use a normal cosine function everythig works out perfectly and I get the original yd==y .

But in this particular case of a qudratic cosine it is not working. What am I doing wrong?

I would like to thank you in advance for the suggestions. They would be very helpful.

Regards,

Ida

For real values signals, which can be thought of as the sum of two complex signals, the situation isn't as straightforward.

The effect of the phase (phi) in the results of a DFT can be found by examining the equations in two of my blog articles.

For complex pure tones:

"DFT Bin Value Formulas for Pure Complex Tones"

https://www.dsprelated.com/showarticle/1038.php

Equations (14) and (16)

For real pure tones:

"DFT Bin Value Formulas for Pure Real Tones"

https://www.dsprelated.com/showarticle/771.php

Equations (23) - (25)

Hope this helps.

Ced

Thank you for the reply but i tried it with a complex signal and it is still not working.

However the information on the blog was very helpful. :)

Ida,

(Minor correction: pi/3=1.047... is not a 1 second delay, 1 is a 1 second delay)

Your problem isn't real signals.

Your problem is your expectations.

Your code

for k = 1:SIZE

L(k) = Y2(k)*exp(-(1i*2*pi*f1(k)*delay));

end

yd = real(ifft(L));

will restore a circular advance (for delay>0, as used, you did an advance, not a delay).

But going from y to y1 you did not do a circular advance.

You cut off the front of the y waveform (advance) and created the same number of data points to append to the end of the y waveform using the equation you used for the original signal. The equation you used is not periodic within the FFT length, so it was not a circular advance.

Since going from y to y1 you did not do a circular advance, using a method to restore a circular advance should give you no expectation that you will get the original signal, i.e. get yd=y. y and yd should not be the same.

Dirk Bell

Hi Dirk,

Thank you so much for your reply.

I see your point. But the period of a cosine is 2*pi right? Even with this fft length it is not working. What am I still missing?

thank you in advance

You are not working with a time domain cosine signal that has repetitive equal periods. You are working with a linear swept tone that linearly increases in frequency with time. Correspondingly, the period is continuously decreasing as time increases over the time you are generating it.

You do need to understand the y1 is neither an advanced or delayed version of y over any finite time period.

Dirk Bell

So what I think now the problem is (after your explanation): a qudratic cosine (the one I am generating) is not periodic? Therefore I cannot restore a circular advance. But if I use a simple cosine, it works because the signal is periodic within the fft length?

Thank a lot :)

Not exactly. Look at the more general case.

It is possible to have advances and delays whose lengths are the sum of integer and fractional numbers of samples, but to simplify the discussion, we will limit the discussion to advances and delays that are an integer number of samples (Your advance was 800 samples for 1 second, after pi/3 was replaced by 1).

The rest of the discussion will only discuss original advances, also to simplify the discussion. It can easily be extended to original delays.

Your original post dealt with using a linear phase adjustment prior to an IFFT (implementing a circular delay), to remove a signal advance. Since we are using an IFFT, the signal we are dealing with at that point is finite, with length we label NFFT (You used NFFT=3200 for 4 seconds at 800sps).

Your approach using a linear phase adjustment to implement a delay to remove an advance only works to remove a circular advance (or an advance that could be represented as a circular advance, the possibility of which would depend on the signal). A circular advance of M points (where M)>

Now lets suppose you have an "original" signal of length NLEN greater than NFFT+M (NLEN could be finite or infinite). You advance the "original" signal by removing the first M points and moving the remaining points forward. You will select the first NFFT points left to work with to try to remove the advance using the method you implemented and recover the "original" NFFT samples.

When you apply your method will you recover the first NFFT points of the "original" signal? REQUIREMENT: You will ONLY if in the "original" signal the samples 0 to M-1 are identical to the samples NFFT+0 to NFFT+M-1. That is because that is what is required to make an advance and a circular advance identical.

Note that so far I have made no mention of periodicity. Periodicity was not a requirement. However, if the first NFFT+M points of the "original" signal have period M, and NFFT is an integer multiple of M, the REQUIREMENT will be met.

What about a non-periodic "original" signal? As an example, suppose the first M+NFFT points of the "original" signal were as follows: M zero samples, NFFT-M arbitrary samples, M zero samples (so first and last M point intervals described match, meeting the REQUIREMENT). You advance the "original" signal by removing the initial M zero samples, leaving the next NFFT samples made of the NFFT-M arbitrary samples, followed by M zero samples. Now if you take an NFFT point FFT and use your method, you will perform a compensating M point circular delay, which will move the last M zero samples in front of the NFFT-M arbitrary samples. The result will match the first NFFT points of the "original" signal before the advance.

Clear as mud?

Dirk Bell

not as clear as crystal but not as bad as mud :P I understand now your point completely. Thank you so much for giving it the time. I greatly appreciate it :)

I do not know if what you are looking for is in a "Guide to FFT" that I've done several years ago. https://it.mathworks.com/matlabcentral/fileexchang...

I've used real signal and all works without the necessity to use the function real().

This script shows also how to delay a signal of a period not related with the sampling time.

Daniele