How to do a phase shift of a signal
379 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
Respuestas (7)
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
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).
https://www.mathworks.com/matlabcentral/answers/483938-time-shifting-an-audio-in-a-frequency-domain?s_tid=mwa_osa_a
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
0 comentarios
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);
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);
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
0 comentarios
Malwinder Singh
el 27 de Jul. de 2018
Editada: Voss
el 30 de Oct. de 2024 a las 15:42
clc;
clear all;
close all;
IF=10e6;
FS=100e6;
TS=1/FS;
L=256;
n=1:L;
t0=0.1*(TS);%% shifted 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
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
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
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
0 comentarios
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
0 comentarios
Ver también
Categorías
Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!