Phase shift correct estimation

9 visualizaciones (últimos 30 días)
TTA
TTA el 25 de Mayo de 2023
Comentada: David Goodmanson el 26 de Mayo de 2023
Hello
I'm in need of some help if you please.
In the attached text file I have 3 columns, column 1 is the altitude from 20 to 110 km with an interval of 0.1km.
the other 2 columns are signals.
Please I want to calculate the phase shift between the signals in columns 2 and 3 as a function of the altitude to range from 0 to pi.
Here is a portion of the code for further understanding :
Please, any solution is welcome.
Pathf = "Signal_Test_Data.txt";
data = flipud(load(Pathf));
tt = data(:, 1);
Xt = data(:, 2);
Yt = data(:, 3);
tx = (data_alt>=20 & data_alt<=110);
t = tt(tx);
X = Xt(tx);
Y = Yt(tx);
figure; plot(t, x, t, y);
legend('x','y');
xh = hilbert(x);
yh = hilbert(y);
xphase = unwrap(angle(xh));
yphase = unwrap(angle(yh));
figure; plot(t, xphase, t, yphase,'.');
phase_diff = wrapToPi(xphase-yphase);
figure; plot(t, phase_diff, '-');
  5 comentarios
TTA
TTA el 26 de Mayo de 2023
Yeah....I needed a phase shift that ranges from 0 to π.
David Goodmanson
David Goodmanson el 26 de Mayo de 2023
Hi TTA,
Since phase shift runs from -pi to pi, or 0 to 2pi, or any other limits you choose whose range is 2pi, do you have a reason for the expectation that the range of phase angle in this case will have a range of only pi? The data does not appear to be cooperating.

Iniciar sesión para comentar.

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 25 de Mayo de 2023
Editada: Sulaymon Eshkabilov el 25 de Mayo de 2023
Here is how to compute the phase difference between two signals:
Pathf = 'Signal_Test_Data.txt';
data = flipud(load(Pathf));
tt = data(:, 1);
Xt = data(:, 2);
Yt = data(:, 3);
t = tt(:);
X = Xt(:);
Y = Yt(:);
figure;
plot(t, X, t, Y)
legend('x','y')
title('Data')
% Remove any offsets
X = X-mean(X);
Y = Y-mean(Y);
Tstep = 0.1; % Step size
Fs = 1/Tstep; % Sampling frequency
% Calculate FFT:
fft_x = fft(X);
fft_y = fft(Y);
N = ceil((numel(t)+1)/2);
freq = (0:N-1)*Fs/numel(t);
figure
subplot(211)
plot(freq, abs(fft_x(1:N)))
xlabel('Freq')
ylabel('|X|')
title('FFT of x and y signals')
subplot(212)
plot(freq, abs(fft_y(1:N)))
xlabel('Freq')
ylabel('|Y|')
% Find max values of the computed FFT of x and y signals
[Max_X, IDX_X] = max(abs(fft_x));
[Max_Y, IDX_Y] = max(abs(fft_y));
Phase_X = angle(fft_x(IDX_X));
Phase_Y = angle(fft_y(IDX_Y));
Phase_Diff = Phase_X-Phase_Y;
fprintf('Estimated phase shift: %f [rad] \n', Phase_Diff)
Estimated phase shift: 0.784554 [rad]
fprintf('Estimated phase shift: %f [deg] \n', rad2deg(Phase_Diff))
Estimated phase shift: 44.951634 [deg]
  1 comentario
TTA
TTA el 25 de Mayo de 2023
Editada: TTA el 25 de Mayo de 2023
Thanks @sulaymon. Please, I can get the phase shift estimate as function of altitude. I mean the phase shift at each altitude?
I will be very grateful

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by