How to do a phase shift of a signal

515 visualizaciones (últimos 30 días)
moeen saeed
moeen saeed el 13 de Ag. de 2012
Editada: Yvonne Haesevoets el 13 de Jun. de 2023
Hello,
I want to do a phase shift of a signal and I can't get the right method to do it. What I am doing is that first I do the FFT of the signal and then I get Phase and Magnitude. In the phase I add or subtract the value to be shifted and then I use the new phase and the old magnitude and do IFFT to get back the signal but what I get is not a shifted signal and also the signal value of the Y axis alos changed which should not be change.
Can any one guide me how to achieve successfully the phase shift without changing the value in y axis.
Thanks
  1 comentario
$$$ $$$
$$$ $$$ el 23 de Jul. de 2018
% % close all; % % clear all; % % x = 0:1e-6:60e-3; % bis 60 ms mit 1µs Schritte % % a = sin(2*pi*50*x); % % b = sin(2*pi*50*x-pi); % % y_rad=acos(dot(a,b)/(norm(a)*norm(b))) % % y_deg=y_rad*360/(2*pi) % % plot(x,a,x,b) % % xlabel(['Winkel in degree ist: ',num2str(y_deg)],'Color','r') % % grid on

Iniciar sesión para comentar.

Respuestas (7)

Jan
Jan el 18 de Ag. de 2012
I'm not sure if I understand the question. Is FFT useful for a phase-shift? What about shifting the phase directly?
x = sin(linspace(0, 10*pi, 10000));
x_shift = zeros(1, numel(x));
x_shift(1:9000) = x(1001:10000);
But perhaps I've overlooked the complexity of the question.
  1 comentario
Yvonne Haesevoets
Yvonne Haesevoets el 15 de Nov. de 2021
Editada: Yvonne Haesevoets el 13 de Jun. de 2023
s/he is looking for fractional phase shifts for which you cannot "shift the phase directly".
For time-shifts by a non-integer number of samples, you need to use a property of the DTFT : a shift in the time-domain amounts to a modulation in the frequency domain (and vice-versa).
Here is a correct implementation (see answer #1 by Prabhan Purwar):
https://www.mathworks.com/matlabcentral/answers/483938-time-shifting-an-audio-in-a-frequency-domain?s_tid=mwa_osa_a

Iniciar sesión para comentar.


majid shaik
majid shaik el 14 de Mayo de 2015
Editada: majid shaik el 14 de Mayo de 2015
I wrote some code to do the same thing it does work but not sure is it right please go through this
% code
clc
clear all
close all
f1=20;
t1=1;
fc=100*f1;
samples=1000;
t=(0:samples-1)/fc;
y=sin(2*pi*f1*t);
t0=1000/fc;
f=linspace(-fc/2,fc/2,samples);
y_ff=fftshift(fft(y));
y_ff2=exp(-j*2*pi*f*t0).*y_ff;
y2=ifft(ifftshift(y_ff2));
plot(t,abs(y2))
hold on
plot(t,y,'r')
grid on

daniel mitchell
daniel mitchell el 24 de Nov. de 2021
Hello, This may help?
t = 0:0.01:2*pi;
x = sin(t);
Possible way 1:
k = 324; % t is of size 629 so if k=324 it corresponds to t(k)=pi approx
delta = zeros(1,length(x)); delta(k)=1;
x_ph = cconv(delta,x,length(x));
figure;
subplot(2,1,1); plot(t,x);
subplot(2,1,2); plot(t,x_ph);
Possible way 2:
X = fft(x);
w = (2*pi/length(x)) * (0:length(x)-1);
k = 324;
X_ph = X.*exp(-1i*w*k);
x_ph = ifft(X_ph);
figure;
subplot(2,1,1); plot(t,x);
subplot(2,1,2); plot(t,x_ph);
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Possible way 3 (complex representation) :
x_complex = exp(1i*t);
x_complex_ph = x_complex*exp(-1i*pi);
x_ph = imag(x_complex_ph); %imag cause imag(e^it)=sin(t)
figure;
subplot(2,1,1); plot(t,x);
subplot(2,1,2); plot(t,x_ph);

$$$ $$$
$$$ $$$ el 23 de Jul. de 2018
% % close all; % % clear all; % % x = 0:1e-6:60e-3; % bis 60 ms mit 1µs Schritte % % a = sin(2*pi*50*x); % % b = sin(2*pi*50*x-pi); % % y_rad=acos(dot(a,b)/(norm(a)*norm(b))) % % y_deg=y_rad*360/(2*pi) % % plot(x,a,x,b) % % xlabel(['Winkel in degree ist: ',num2str(y_deg)],'Color','r') % % grid on

Malwinder Singh
Malwinder Singh el 27 de Jul. de 2018
Editada: Walter Roberson el 8 de Jun. de 2020
clc;
clear all;
close all;
IF=10e6;
FS=100e6;
TS=1/FS;
L=256;
n=1:L;
t0=0.1*(TS);%% shited by 0.1 times of sample time
x_real=cos(2*pi*(IF/FS)*n);
x_imag=sin(2*pi*(IF/FS)*n);
sig_vect=complex(x_real,x_imag);
fft_out=fft(sig_vect);
fft_shifted=exp(-2i*pi*(IF)*t0)*fft_out;
sig_time_shifted=ifft(fft_shifted);
figure(1)
plot(real(sig_vect),'r*-')
hold on
plot(real(sig_time_shifted),'g*-')
grid on;
  2 comentarios
Asaf Haddad
Asaf Haddad el 26 de Oct. de 2020
There is no point in the fft and ifft here, since are simply multiplying with a constant phase. It doesn't matter if you multiply the signal or it transform.
Yvonne Haesevoets
Yvonne Haesevoets el 15 de Nov. de 2021
for fractional phase shifts, there is no other way than to do it by application of one of the DTFT's properties : time shift => modulation in frequency

Iniciar sesión para comentar.


Akanksha Pathak
Akanksha Pathak el 6 de Nov. de 2019
For a signal, π f t) with frequency f , if we want to provide phase shift of ϕ radian,
Equation 1: ϕ=2πf, where is delay in time
Equation 2: =sin(2 πft+ ϕ)
In case, we want to provide phase shift of θ degree, then
Equation 3: θ=360 f
Compute the required delay using equation 3, compute corresponding delay in radian using equation 1, and use it to generate phase shift in using equation 2.
Hope this answers

Ties
Ties el 3 de Dic. de 2021
I have the same question.
Only i use FT function of Matlab. If I want to have the phase shift of the signal, can I use the FFTshift function of matlab

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by