I am trying to verify the following identity in Matlab for the Fourier transform of a shifted signal: F{x(t-t0)}={exp(-j*2*pi*F*t0)}. Say that my initial signal starts at position 1 of the vector. Basically, I start by adding some K_left_max zeros at the beggining and K_right_max at the end of the signal which represent the maximum shifting duration I will probably need to the left and right respectively, in terms of samples. Then, I take the fft of this signal. Based on the previous property, I now have to multiply this transform by {exp(+j*2*pi*F*K_left_max*Ts)} since I have to cancel the delay I have after adding the K_left_max zeros to the initial signal. Then I take this fft and I multiply it by the shifting I have, say K samples (K>0 => delay, K<0 => advancing). Finally, I compare this fft with the fft of the signal delayed in time domain.
Here is the code:
N=10;
K_left_max=10;
K_right_max=10;
x0=rand(1,N);
x=[zeros(1,K_left_max) x0 zeros(1,K_right_max)];
Ts=0.25;
Fs=1/Ts;
X=Ts*fftshift(fft(x));
F=[-Fs/2:Fs/(K_left_max+N+K_right_max):Fs/2-Fs/(K_left_max+N+K_right_max)];
X=X.*exp(1j*2*pi*F*K_left_max*Ts);
An example of delay:
K=1;
left=zeros(1,K_left_max+K);
y=[left x0 zeros(1, length(x)-length(left)-length(x0))];
Y=Ts*fftshift(fft(y));
Y=Y.*exp(1j*2*pi*F*K_left_max*Ts);
Yother=X.*exp(-1j*2*pi*F*K*Ts);
An example of advancing:
K=-5;
left=zeros(1,K_left_max+K);
y=[left x0 zeros(1, length(x)-length(left)-length(x0))];
Y=Ts*fftshift(fft(y));
Y=Y.*exp(1j*2*pi*F*K_left_max*Ts);
Yother=X.*exp(-1j*2*pi*F*K*Ts);
Please note that the following relations should hold: K <= K_right_max for right shifting and abs(K) <= K_left_max for left shifting.
This method seems to work fine (Yother has the same value as Y) but I have two questions:
- 1. K_left_max+N+K_right_max i.e. the signal length need to a multiple of Fs for this to work. Why?
- 2. Is my thought about shifting to the left correct? Basically, if I had to do only delays, I would only zero pad the end of the signal which would be less to worry about.