Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

finding phase using autocorrelation

Status
Not open for further replies.

ashwini1

Member level 1
Member level 1
Joined
Jul 17, 2009
Messages
32
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Bangalore
Activity points
1,483
Hi,

I have a 30Hz wave, where i have introduced a phase shift of 45 degrees. Somewhere i read that the phase info can be computed based on auto correlation function. I tried and i did not get required output. Here is my code, can anyone tell me that what is wrong in this.

Fs=100e3;
t=[0:Fs]/Fs;
x=sin(2*pi*30*t+(45*pi/180));
c=xcorr(x);
t1=[-100e3:100e3];
plot(t1,c);

[val,index]=max(c);
lag=t1(index);
ph=lag*180/pi;

i suppose to get ph=45; instead i am getting 0.

Any help plz ..
Thanks,
Ashwini
 

Hi

The following code will give you the phase offset.

Fs=100e3;
t=[0:Fs]/Fs;
x=sin(2*pi*30*t+(15*pi/180));
y=sin(2*pi*30*t);
c=xcorr(y,x);
t1=[-100e3:100e3]/Fs*2*pi*30;
plot(t1,c);

[val,index]=max(c);
lag=t1(index);
ph=lag*180/pi;
 

Thanks for your reply,

can you plz explain me this:
t1=[-100e3:100e3]/Fs*2*pi*30;

why are you diving t1 by the factor:Fs*2*pi*30.

Is it to change the units from sec to radians.

Thanks
Ashwini
 

Hi Ashwini
ashwini1 said:
why are you diving t1 by the factor:Fs*2*pi*30.
Firstly I am not dividing by Fs*2*pi*30.
I am dividing by Fs and multiplying by 2*pi*30.

Division by Fs makes 't1' time axis i-e if you observe that division by Fs makes the variable 't1' having dimensions of time.

Then I multiplied it with 2*pi*30 to convert this time lag into phase lag!

This time give me Thanks by clicking Helped me :D
 

    ashwini1

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top