how to estimate the phases of the sum of 2 sinusoidal signals

4 views (last 30 days)
Hi all,
I am trying to estimate the 2 phases of a sum of 2 sinusoids: A1*cos(t/T1+phi1)+A2*cos(t/T2+phi2). I already estimated the amplitudes and the periods, but I cannot manage to estimate the phases phi1 and phi2. Should I be using the fft for this or should I use another method?
Many thanks,
Here is the code:
timesignal = (0:1/100:1000-1/100); % Time vector
signal = cos(2*pi*timesignal/1+95*pi/180) + 2*cos(2*pi*timesignal/0.5+140*pi/180); % Signal
dt=timesignal(2)-timesignal(1);
Fs = 1/dt; % Sampling frequency
T = 1/Fs; % Sample time
L = length(signal); % Length of signal
filterH=hanning(L)';
Y = fft(signal.*filterH)/L;%fft of signal
f = Fs*linspace(0,1,L/2+1)/2; %freq
m=2*abs(Y(1:length(f))); %magnitude fft
p = unwrap(atan2(imag(Y(1:length(f))),real(Y(1:length(f))))); %phase fft
[Y2,I]=max(m); %magnitude highest peak
amplitude1=m(I) %A1
period1=1/f(I) %T1
phase1=mod(p(I)*180/pi,360) %phi1
m(I-5:I+5)=0; %remove highest peak ->may need to be improve
[Y2,I]=max(m);
amplitude2=m(I)
period2=1/f(I)
phase2=mod(p(I)*180/pi,360)

Answers (1)

V
V on 11 Jun 2013
Edited: V on 11 Jun 2013
Hello, actually I noticed that my code is working in some cases but not all of them and I cannot figure out why.
for signal = cos(2*pi*timesignal/1+95*pi/180) + 2*cos(2*pi*timesignal/0.5+140*pi/180);
it is estimating the 2 phases correctly, but for : signal = cos(2*pi*timesignal/1+95*pi/180) + 2*cos(2*pi*timesignal/0.49+140*pi/180);
(the only thing I changed is the period T2 of the second cosinus), the estimation of the phase of the second cosinus is incorrect (107 instead of 140). So why does it work sometimes but not all the time and what can I do to correct it? Is this method with the fft a good method or should I use another method?
Many thanks,

Community Treasure Hunt

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

Start Hunting!