DSPRelated.com
Forums

Help! Phase difference of two signals

Started by jade October 11, 2007
Hello,

I am trying to get the phase difference of two signals.
They are at the same frequency.
The phase value of each signal is calculated by the angle function of 
a signal's FFT.
One thing I could not understand is that the absolute phase value of
each signal changes with the sample size of the FFT but the phase
difference between the two signals keeps the same. I am not so sure
whether the unwrap function makes any difference here.

Also,do I need use window for the FFT processing?

Thanks,
Jade

%%%sampling freq
clear all
fo=10.23*10^6;
%%%sampling_resolution(s)
%res=100;
fs=100.5*10^6;
%%%duration=10048/fs

duration=0.9999*10^(-4);
%duration=10*10^(-4);
t = 0:1/fs:duration-1/fs;
tp=1*10^(-8);
theta0=0;
x1 = sin(2*pi*fo*t+theta0);
x2 = sin(2*pi*fo*(t+tp)+theta0);

s1=x1;
s2=x2;

s11=s1;
y1 =fft(s11);
N=length(y1);
 y = y1*2/N;
 m = abs(y);
 m(1)=m(1)/2;

TTT=round(mod(fo,fs)*N/fs+1);
y(TTT)
theta11=unwrap(angle(y(TTT)));
theta12=(angle(y(TTT)));

s12=s2;
y2 =fft(s12);
N=length(y2);
 y = y2*2/N;
 m = abs(y);
 m(1)=m(1)/2;
TTT=round(mod(fo,fs)*N/fs+1);

y(TTT)
theta21=unwrap(angle(y(TTT)));
theta22=(angle(y(TTT)));

(theta21-theta11)/2/pi/fo



On 12 Okt, 04:58, "jade" <yunqiyun...@gmail.com> wrote:
> Hello, > > I am trying to get the phase difference of two signals. > They are at the same frequency.
... Why do you re-post the same question you asked two days ago? Rune
Since you're only interested in one frequency, you can multiply the signal
with a complex rotating phasor of the same frequency, and integrate/sum
over a number of periods.

-mn
>>Why do you re-post the same question you asked two
days ago? Same question here. -mn
Rune Allnor wrote:
> On 12 Okt, 04:58, "jade" <yunqiyun...@gmail.com> wrote: >> Hello, >> >> I am trying to get the phase difference of two signals. >> They are at the same frequency. > ... > > Why do you re-post the same question you asked two > days ago? > > Rune > >
Its a phase shift thing. You compare the answers to two similar questions asked out of phase, then correlate for consistency in the answers. :-) Steve
Steve Underwood <steveu@dis.org> writes:

> Rune Allnor wrote: >> On 12 Okt, 04:58, "jade" <yunqiyun...@gmail.com> wrote: >>> Hello, >>> >>> I am trying to get the phase difference of two signals. >>> They are at the same frequency. >> ... >> Why do you re-post the same question you asked two >> days ago? >> Rune >> > Its a phase shift thing. You compare the answers to two similar > questions asked out of phase, then correlate for consistency in the > answers. :-)
You can also reduce the noise by averaging... -- % Randy Yates % "She's sweet on Wagner-I think she'd die for Beethoven. %% Fuquay-Varina, NC % She love the way Puccini lays down a tune, and %%% 919-577-9882 % Verdi's always creepin' from her room." %%%% <yates@ieee.org> % "Rockaria", *A New World Record*, ELO http://www.digitalsignallabs.com
Steve Underwood wrote:
> Rune Allnor wrote: >> On 12 Okt, 04:58, "jade" <yunqiyun...@gmail.com> wrote: >>> Hello, >>> >>> I am trying to get the phase difference of two signals. >>> They are at the same frequency. >> ... >> >> Why do you re-post the same question you asked two >> days ago? >> >> Rune >> >> > Its a phase shift thing. You compare the answers to two similar > questions asked out of phase, then correlate for consistency in the > answers. :-)
Maybe the phase shift is to make sure there's no dead center. Consider a two-cylinder steam engine. One problem, though. It's hard to ask questions in quadrature without knowing the period. Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
On Oct 12, 2:30 pm, Jerry Avins <j...@ieee.org> wrote:
> Steve Underwood wrote: > > Rune Allnor wrote: > >> On 12 Okt, 04:58, "jade" <yunqiyun...@gmail.com> wrote: > >>> Hello, > > >>> I am trying to get the phase difference of two signals. > >>> They are at the same frequency. > >> ... > > >> Why do you re-post the same question you asked two > >> days ago? > > >> Rune > > > Its a phase shift thing. You compare the answers to two similar > > questions asked out of phase, then correlate for consistency in the > > answers. :-) > > Maybe the phase shift is to make sure there's no dead center. Consider a > two-cylinder steam engine. One problem, though. It's hard to ask > questions in quadrature without knowing the period.
Maybe the OP is still trying to collect enough reply samples to estimate the period? There's also a decay parameter to be estimated: how long on average will a particular Q&A thread stay on topic? Or perhaps two universities are teaching the same course, but with offset semester start dates, so the automated DSP-homework-question-asking bot net got two initiate commands instead of one?
Sorry. I am new to this website.
I thought this website and the google discussion group are different...

Jade

>On 12 Okt, 04:58, "jade" <yunqiyun...@gmail.com> wrote: >> Hello, >> >> I am trying to get the phase difference of two signals. >> They are at the same frequency. >... > >Why do you re-post the same question you asked two >days ago? > >Rune > > >
: ) 

Really apologize. Did not mean to correlate for consistency in the
answers.
Just one post got delayed. It seems that the post through google
discussion 
group is faster.

Thanks for the help from all your guys...

Jade

>Steve Underwood <steveu@dis.org> writes: > >> Rune Allnor wrote: >>> On 12 Okt, 04:58, "jade" <yunqiyun...@gmail.com> wrote: >>>> Hello, >>>> >>>> I am trying to get the phase difference of two signals. >>>> They are at the same frequency. >>> ... >>> Why do you re-post the same question you asked two >>> days ago? >>> Rune >>> >> Its a phase shift thing. You compare the answers to two similar >> questions asked out of phase, then correlate for consistency in the >> answers. :-) > >You can also reduce the noise by averaging... >-- >% Randy Yates % "She's sweet on Wagner-I think she'd
die for Beethoven.
>%% Fuquay-Varina, NC % She love the way Puccini lays down a
tune, and
>%%% 919-577-9882 % Verdi's always creepin' from her
room."
>%%%% <yates@ieee.org> % "Rockaria", *A New World Record*, ELO
>http://www.digitalsignallabs.com >