Phase shift correct estimation

조회 수: 8 (최근 30일)
TTA
TTA 2023년 5월 25일
댓글: David Goodmanson 2023년 5월 26일
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
TTA
TTA 2023년 5월 26일
Yeah....I needed a phase shift that ranges from 0 to π.
David Goodmanson
David Goodmanson 2023년 5월 26일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 5월 25일
편집: Sulaymon Eshkabilov 2023년 5월 25일
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
TTA
TTA 2023년 5월 25일
편집: TTA 2023년 5월 25일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by