How to do a phase shift of a signal
120 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
$$$ $$$
le 23 Juil 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
Réponses (7)
Jan
le 18 Août 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 commentaire
Yvonne Haesevoets
le 15 Nov 2021
Modifié(e) : Yvonne Haesevoets
le 13 Juin 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
le 14 Mai 2015
Modifié(e) : majid shaik
le 14 Mai 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 commentaires
daniel mitchell
le 24 Nov 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);
$$$ $$$
le 23 Juil 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 commentaires
Malwinder Singh
le 27 Juil 2018
Modifié(e) : Voss
le 30 Oct 2024
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 commentaires
Asaf Haddad
le 26 Oct 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
le 15 Nov 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
le 6 Nov 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 commentaires
Ties
le 3 Déc 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 commentaires
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!