clc; clear all; close all;

sample_rate=10000; % Set Up
dt=1/sample_rate;
len=0.01;
t=0:dt:(len-dt);
f=500;
N = length(t);

%generate signalnal
signal=sin(2*pi*f*t);

%Define a phase shift in rads
phase = pi/4;
num_samp = round((sample_rate/f)*(phase/(2*pi)));

%Get the FFT of the signalnal
signalfft =fft(signal);

%Rotate each FFT component
k=1:length(signalfft);
w = 2*pi/N*(k-1); % Range of Phasor phase values
spec=signalfft.*exp(-j*w*num_samp);

%Get the new signalnal
newsignal=(ifft(spec));

%plot the signalnals
figure;plot(t,real(signal));hold on; plot(t,real(newsignal),'g');
