Shift in Time Domain by altering Fourier-Coefficients

fourier transformMATLABtime series

I want to apply a circular shift to a time-series, by changing the phase of the fourier-coefficients. But I run into trouble. In the current state the true sequence starts in the middle of the time-series. So thought that, I could do a phase shift in the frequency domain, by running this matlab command:

[x,fs]= audioread("sound.wav");
x= x(:,1)';
x = real(ifft(fft(x).*exp(-i*pi))) 

Since the signal can be seen as a linear combination of periodic functions i should be able to find a phase-term to make my desired shift in the time-domain. But it does not behave as I expected.

Is it possible to do it like that? What am I not seeing here? The following shows the signal I want to modify.
enter image description here

I want it to be shifted to that:
shifted to the right position

Best Answer

A delay of $\tau$ seconds corresponds to a multiplication with $e^{-\tau s} = e^{- i \tau \omega}$ in the Laplace/Fourier domain. You need to add a multiplication with a radial frequency vector in the exponent exp(-i*pi). Also, I prefer to use either 1i or 1j instead of i to make sure it corresponds to $\sqrt{-1}$.

The Matlab code becomes

[x,fs]= audioread("sound.wav");
x= x(:,1)';
N = length(x);
w = 2*pi*(0:N-1)/N;
tau = 123; % choose an appropriate value
x = real(ifft(fft(x).*exp(-1i*tau*w*pi)));