how to estimate the phases of the sum of 2 sinusoidal signals
Show older comments
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)
Categories
Find more on Fast Fourier Transforms 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!