From: jayashree bulusu on 28 Jul 2010 07:37 Hello, I am working on the data of magnetic fields.I need to obtain the cross phase between two time series. also i would like to know How to dynamic cross phase spectrum between two signals using matlab
From: Wayne King on 28 Jul 2010 08:01 "jayashree bulusu" <bulusujayashree(a)gmail.com> wrote in message <i2p4p0$437$1(a)fred.mathworks.com>... > > Hello, > I am working on the data of magnetic fields.I need to obtain the cross phase between two time series. also i would like to know > How to dynamic cross phase spectrum between two signals using matlab Hi Jayashree, In the Signal Processing Toolbox, cpsd() returns the (complex-valued) cross-spectrum of two stationary time series. You can obtain the relative phase information between the two time series as the inverse tangent of the negative of the quadrature spectrum (imaginary part of the cross-spectrum) divided by the co-spectrum (real part of the cross spectrum). Hope that helps, Wayne
From: jayashree bulusu on 28 Jul 2010 12:05 "Wayne King" <wmkingty(a)gmail.com> wrote in message <i2p662$5da$1(a)fred.mathworks.com>... > "jayashree bulusu" <bulusujayashree(a)gmail.com> wrote in message <i2p4p0$437$1(a)fred.mathworks.com>... > > > > Hello, > > I am working on the data of magnetic fields.I need to obtain the cross phase between two time series. also i would like to know > > How to dynamic cross phase spectrum between two signals using matlab > > Hi Jayashree, > > In the Signal Processing Toolbox, cpsd() returns the (complex-valued) cross-spectrum of two stationary time series. You can obtain the relative phase information between the two time series as the inverse tangent of the negative of the quadrature spectrum (imaginary part of the cross-spectrum) divided by the co-spectrum (real part of the cross spectrum). > > Hope that helps, > Wayne hello Wayne Thanks for that information. i have tried the following Matlab code. can you suggest if my code is right??? secondly, this gives me a static plot. what if i need a dynamic plot with similar crossphase information. clc clear all t=(0:99)/100; x1=sin(2*pi*t)+cos((pi*t)/2); x2=cos(2*pi*t)+cos(5*pi*t+pi/2); [pxy,f]=cpsd(x1,x2,[],[],128,100); cr=atan2(imag(pxy),real(pxy)); plot(f,cr) Looking forward to your reply, Thank you Jayashree
From: Wayne King on 28 Jul 2010 12:39 "jayashree bulusu" <bulusujayashree(a)gmail.com> wrote in message <i2pkg1$hh8$1(a)fred.mathworks.com>... > "Wayne King" <wmkingty(a)gmail.com> wrote in message <i2p662$5da$1(a)fred.mathworks.com>... > > "jayashree bulusu" <bulusujayashree(a)gmail.com> wrote in message <i2p4p0$437$1(a)fred.mathworks.com>... > > > > > > Hello, > > > I am working on the data of magnetic fields.I need to obtain the cross phase between two time series. also i would like to know > > > How to dynamic cross phase spectrum between two signals using matlab > > > > Hi Jayashree, > > > > In the Signal Processing Toolbox, cpsd() returns the (complex-valued) cross-spectrum of two stationary time series. You can obtain the relative phase information between the two time series as the inverse tangent of the negative of the quadrature spectrum (imaginary part of the cross-spectrum) divided by the co-spectrum (real part of the cross spectrum). > > > > Hope that helps, > > Wayne > hello Wayne > > Thanks for that information. > i have tried the following Matlab code. can you suggest if my code is right??? > secondly, this gives me a static plot. what if i need a dynamic plot with similar crossphase information. > > clc > clear all > > t=(0:99)/100; > x1=sin(2*pi*t)+cos((pi*t)/2); > x2=cos(2*pi*t)+cos(5*pi*t+pi/2); > [pxy,f]=cpsd(x1,x2,[],[],128,100); > cr=atan2(imag(pxy),real(pxy)); > plot(f,cr) > > > Looking forward to your reply, > > Thank you > > Jayashree Hi Jayashree, I apologize that I don't have time at the moment to delve into your example (I'll try to look at it in a bit), but consider this one: Fs = 1000; t = 0:(1/Fs):1-(1/Fs); x = cos(2*pi*100*t)+randn(size(t)); % note the relative phase difference between the x and y y = cos(2*pi*100*t-pi/4)+randn(size(t)); [Pxy,F] = cpsd(x,y,200,50,200,Fs); plot(F,abs(Pxy)); [~,index] = max(abs(Pxy)); Ph = atan2(-imag(Pxy),real(Pxy)); plot(F,Ph); % note the value of Ph(index) Ph(index) For me the answer is -0.7948 very close to the true -pi/4. Obviously, the use of randn() will not produce the exact value for you, but you should see that it is close. Wayne
From: jayashree bulusu on 29 Jul 2010 10:19
"Wayne King" <wmkingty(a)gmail.com> wrote in message <i2pmf8$sqv$1(a)fred.mathworks.com>... > "jayashree bulusu" <bulusujayashree(a)gmail.com> wrote in message <i2pkg1$hh8$1(a)fred.mathworks.com>... > > "Wayne King" <wmkingty(a)gmail.com> wrote in message <i2p662$5da$1(a)fred.mathworks.com>... > > > "jayashree bulusu" <bulusujayashree(a)gmail.com> wrote in message <i2p4p0$437$1(a)fred.mathworks.com>... > > > > > > > > Hello, > > > > I am working on the data of magnetic fields.I need to obtain the cross phase between two time series. also i would like to know > > > > How to dynamic cross phase spectrum between two signals using matlab > > > > > > Hi Jayashree, > > > > > > In the Signal Processing Toolbox, cpsd() returns the (complex-valued) cross-spectrum of two stationary time series. You can obtain the relative phase information between the two time series as the inverse tangent of the negative of the quadrature spectrum (imaginary part of the cross-spectrum) divided by the co-spectrum (real part of the cross spectrum). > > > > > > Hope that helps, > > > Wayne > > hello Wayne > > > > Thanks for that information. > > i have tried the following Matlab code. can you suggest if my code is right??? > > secondly, this gives me a static plot. what if i need a dynamic plot with similar crossphase information. > > > > clc > > clear all > > > > t=(0:99)/100; > > x1=sin(2*pi*t)+cos((pi*t)/2); > > x2=cos(2*pi*t)+cos(5*pi*t+pi/2); > > [pxy,f]=cpsd(x1,x2,[],[],128,100); > > cr=atan2(imag(pxy),real(pxy)); > > plot(f,cr) > > > > > > Looking forward to your reply, > > > > Thank you > > > > Jayashree > > Hi Jayashree, I apologize that I don't have time at the moment to delve into your example (I'll try to look at it in a bit), but consider this one: > > Fs = 1000; > t = 0:(1/Fs):1-(1/Fs); > x = cos(2*pi*100*t)+randn(size(t)); > % note the relative phase difference between the x and y > y = cos(2*pi*100*t-pi/4)+randn(size(t)); > [Pxy,F] = cpsd(x,y,200,50,200,Fs); > plot(F,abs(Pxy)); > [~,index] = max(abs(Pxy)); > Ph = atan2(-imag(Pxy),real(Pxy)); > plot(F,Ph); > % note the value of Ph(index) > Ph(index) > > For me the answer is -0.7948 very close to the true -pi/4. Obviously, the use of randn() will not produce the exact value for you, but you should see that it is close. > > Wayne hi thanks for the reply. It was informative. the plot that i obtain from there is the static plot. can you suggest some method to obtain the dynamic spectra of the same. Thank you, Jayashree |