Phase shift correct estimation
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
David Goodmanson
il 26 Mag 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.
Risposte (1)
Sulaymon Eshkabilov
il 25 Mag 2023
Modificato: Sulaymon Eshkabilov
il 25 Mag 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)
fprintf('Estimated phase shift: %f [deg] \n', rad2deg(Phase_Diff))
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!