How to find phase shift and do phase shift correction between two signals in frequency domain?

I have 2 time domain signals collected from Terahertz Time Domain Spectroscopy (Reflection); reference and sample. I managed to find out the time delay between the two signals. And I thought by aligning the peak of two signals in time domain will correct the phase shift problem in frequency spectrum. But it does not seem to work this way. Therefore,I thought can explore the option of finding phase shift between the two signals in a particular frequency spectrum before correcting the phase shift.
Can someone kindly enlighten me how to find phase shift between the two signal in the frequency spectrum and how to correct phase shift in the frequency spectrum? Really any help will be deeply appreciated.

1 Comment

You can use cross-correlation as in [c,lags]= xcorr (sig1, sig2); and follow the rest of the procedure as in the examples.

Sign in to comment.

 Accepted Answer

You have not provided enough information to provide a specific response. Note that if your signal contains multiple frequencies, as the Wikipedia article appears to indicate, it may not be possible to get all the phase angles to zero.
Since you mentioned analysing your signals in the frequency domain, I assume you are already familiar with the fft (link) function. Use the angle (link) function on the complex output of the fft to get the phase. You can use this utility function to convert angles going from 0 to ±pi to angles going from 0 to 2*pi. That could make the angle comparisons easier:
Angles2pi = @(a) rem(2*pi+a, 2*pi); % For ‘atan2’
Also consider using the unwrap (link) function.
If you provide more information, we may be able to provide a more specific response.

4 Comments

Hi Star Strider. Thank you so much for your comments.
Is the phase shift determined by taking difference in the phase angle of the 2 signals? And the phase shift correction is done by minus the difference from the phase angle of the sample?
Indeed my signal, after FFT , will have multiple frequencies.Is it possible to only perform phase shift correction to only a certain range of frequencies?
Can I also check something? If my time domain signal consists of two columns of data sets,time and amplitude,is the following way to fft the signal to get frequency is correct?
%Reading reference file
[X_REF,TXT_REF,RAW_REF] = xlsread('reference.xls');
%fft raw data (reference)
Reference = fft(X_REF(:,2));
% for odd no of data % sampling interval -- assuming equal sampling
DT = X_REF(2,1)-X_REF(1,1);
% sampling frequency
Fs = 1/DT;
DF = Fs/size(X_REF,1);
freq = 0:DF:Fs/2;
Reference = Reference(1:round(length(X_REF)/2));
Or should I also fft the time column to get the frequency spectrum?
My pleasure.
‘Is the phase shift determined by taking difference in the phase angle of the 2 signals?’
That is one option if they are less than 2*pi different. They must be very close together to begin with.
‘And the phase shift correction is done by minus the difference from the phase angle of the sample?’
That is one option. They have to be less than 2*pi radians apart, otherwise the angle difference becomes meaningless. You could use the unwrap function, however it takes a ‘best guess’ as to what the phase is for more than 2*pi radians.
‘Is it possible to only perform phase shift correction to only a certain range of frequencies?’
It is not possible to do so reliably for more than one specific frequency.
‘If my time domain signal consists of two columns of data sets,time and amplitude,is the following way to fft the signal to get frequency is correct?’
Partially. I would do something like this:
Time = X_REF(:,1);
Signal = X_REF(:,2);
DT = Time(2)-Time(1); % Sampling Interval (Assumes Constant Sampling Interval)
Fs = 1/DT; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(Time); % Signal Length
Reference = fft(X_REF(:,2))/L; % Normalized Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector (One-Sided Fourier Transform)
Iv = 1:numel(Fv); % Index Vector (One-Sided Fourier Transform)
Reference2 = abs(Reference(Iv))*2; % Scaled One-Sided Fourier Transform
PhaseRadians = angle(Reference(Iv)); % Phase
‘Or should I also fft the time column to get the frequency spectrum?’
No. That will give you no useful information.
Note I am responding to general (and for me hypothetical) questions here, so giving non-specific replies. I have no experience with Terahertz Time-Domain Spectroscopy.
I shall try it out. Really thank you so much for helping out and explaining so much in great details.

Sign in to comment.

More Answers (1)

I need to phase shift the incoming sine signal by 90 degree using matlab coding . what ever the frequency or samples of signal the signal should have shifted by 90 degree. this is possible?? is so please give with input output defined in matlab function. Thanks and regards, Chirag H B

Categories

Find more on Signal Processing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!