# How to circularly shift a signal by a fraction of a sample?

Multiplying $x_n$ by a linear phase $e^{\frac{2\pi i}{N}n m}$ for some integer m corresponds to a circular shift of the output $X_k$: $X_k$ is replaced by $X_{k-m}$, where the subscript is interpreted modulo N (i.e., periodically).

Ok, that works fine:

plot a


N = 9
k = [0, 1, 2, 3, 4, 5, 6, 7, 8]
plot ifft(fft(a)*exp(-1j*2*pi*3*k/N))


It shifted by 3 samples, as I expected.

I thought you could also do this to shift by fractions of a sample, but when I try it, my signal becomes imaginary and not at all like the original:

plot real(ifft(fft(a)*exp(-1j*2*pi*3.5*k/N)))
plot imag(ifft(fft(a)*exp(-1j*2*pi*3.5*k/N))), 'b--'


I didn't expect this at all. Isn't this equivalent to convolving with a real impulse that's been shifted by 3.5 samples? So the impulse should still be real, and the result should still be real? And it should have more or less the same shape as the original, but sinc interpolated?

If you want the shifted output of the IFFT to be real, the phase twist/rotation in the frequency domain has to be conjugate symmetric, as well as the data. This can be accomplished by adding an appropriate offset to your complex exp()'s exponent, for the given phase slope, so that the phase of the upper (or negative) half, modulo 2 Pi, mirrors the lower half in the FFT aperture. The complex exponential shift function can also be made conjugate symmetric by indexing it from -N/2 to N/2 with a phase of zero at index 0.

It just so happens that the appropriate offset for phase twists or spirals, that complete an exact integer multiples of 2 Pi rotations in aperture, to be conjugate symmetric in aperture, is zero.

With a conjugate symmetric phase twist vector, the result should then end up as a circular Sinc interpolation for non-integer shifts.

Elaboration by OP:

Your choice of k = [0, 1, 2, 3, 4, 5, 6, 7, 8] is producing an asymmetrical complex exponential:

If you use k = [0, 1, 2, 3, 4, -4, -3, -2, -1] instead, you get a Hermite-symmetric complex exponential:

plot(fftshift(exp(-1j * 2*pi * 0.5/N * k)))


and now when you use the same exponential formula to shift by 0.5 or 3.5 samples, you get a real result:

plot ifft(fft(a)*exp(-1j * 2 * pi * 0.5/N *k))
plot ifft(fft(a)*exp(-1j * 2 * pi * 3.5/N *k))


• Aha! Instead of k = [0, 1, 2, 3, 4], I should be using k = [0, 1, 2, -2, -1] – endolith Aug 9 '13 at 13:33
• @endolith / hotpaw2, In other words it is all about the indexing of the time-domain samples? – TheGrapeBeyond Aug 9 '13 at 14:58
• Symmetry around bin 0 will also provide symmetry around N/2, even if N/2 isn't an integer. – hotpaw2 Aug 5 '15 at 20:19
• I found a function that applies the correct modulation on Matlab File Exchange: mathworks.com/matlabcentral/fileexchange/7886-fshift 👏! – Ahmed Fasih Aug 6 '15 at 15:39
• does this equally hold for complex signals? – Leo Aug 24 '17 at 14:30