# Time shifting through the frequency domain - DSP

This is a discussion on Time shifting through the frequency domain - DSP ; Dear Group, I could use some help understanding why my attempt to time-shift via the frequency domain is not working and what I need to do to make it work. I thought the Matlab code below would take a 1 ...

1. ## Time shifting through the frequency domain

Dear Group,

I could use some help understanding why my attempt to time-shift via the
frequency domain is not working and what I need to do to make it work.

I thought the Matlab code below would take a 1 Hz sine wave and shift it
1/4 wavelength to the right. It does not.

Have I botched the phase delay? Is my complex-to-real IFFT wrong?

NUM_PTS = 16;
delta = 1/NUM_PTS;
t = [0:delta:1-delta];
x = sin(2*pi*1*t);
y = fft(x, NUM_PTS);
phase_delay = exp(-i*2*pi*4*t/NUM_PTS); % To shift in time by 4/16
samples
y_delayed = phase_delay .* y;
x_shifted = ifft([y_delayed(1:1:length(y_delayed)/2) 0
conj(y_delayed(length(y_delayed)/2:-1:2))]);

x
x_shifted

Thanks very much.

Mikial

2. ## Re: Time shifting through the frequency domain

On Jul 23, 5:24 am, "Mikial Chubarov" <mikialchuba...@ieee.org> wrote:
> Dear Group,
>
> I could use some help understanding why my attempt to time-shift via the
> frequency domain is not working and what I need to do to make it work.
>
> I thought the Matlab code below would take a 1 Hz sine wave and shift it
> 1/4 wavelength to the right. It does not.
>
> Have I botched the phase delay? Is my complex-to-real IFFT wrong?
>
> NUM_PTS = 16;
> delta = 1/NUM_PTS;
> t = [0:delta:1-delta];
> x = sin(2*pi*1*t);
> y = fft(x, NUM_PTS);
> phase_delay = exp(-i*2*pi*4*t/NUM_PTS); % To shift in time by 4/16
> samples
> y_delayed = phase_delay .* y;
> x_shifted = ifft([y_delayed(1:1:length(y_delayed)/2) 0
> conj(y_delayed(length(y_delayed)/2:-1:2))]);
>

You want to shift by 16/4 = 4 samples, not 4/16!

--
Oli

3. ## Re: Time shifting through the frequency domain

>
>
>You want to shift by 16/4 = 4 samples, not 4/16!
>
>
>--
>Oli
>
>

Yikes. Much better! Thank you Oli.

Mikial