how to use a MATLAB function called MC estimator to determine frequency?

조회 수: 2 (최근 30일)
the following is the matlab function for the MC estimator
function w = mc(x);
% w = mc(x) is used to estimate frequency
% the MC method from the vector x
% x is supposed to be a noisy single-tone sequence
% w is the estimated frequency in radian
N=max(size(x));
t1=0;
t2=0;
for n=3:N
t1=t1+x(n-1)*(x(n)+x(n-2));
t2=t2+2*(x(n-1))^2;
end
r = t1/t2;
if (r>1)
r=1;
end
if (r<-1)
r=-1;
end
w=acos(r);
attempted to determine the frequency estimate of the data, which can be found at the following link,using the MC function.
http://solarscience.msfc.nasa.gov/greenwch/spot_num.txt
(please note that the first row and rows after July 2012 are removed)
this is my attempt where the data of thrid column are used only (observing the data, sampling interval is 1 month, that is Fs=1)
load spot_num.txt
ssn = spot_num(:,3);
ssn = ssn-mean(ssn);
x=ssn;
N=max(size(x));
t1=0;
t2=0;
for n=3:N
t1=t1+x(n-1)*(x(n)+x(n-2));
t2=t2+2*(x(n-1))^2;
end
r = t1/t2;
if (r>1)
r=1;
end
if (r<-1)
r=-1;
end
w=acos(r);
w should be close to 0.0076 according to model answer, but somehow i just couldnt get the right answer? could anyone help, thx!

답변 (1개)

Wayne King
Wayne King 2012년 11월 2일
편집: Wayne King 2012년 11월 2일
It may be that this method is just not very robust for noise-corrupted data.
For example:
t = 0:159;
x = cos(pi/4*t);
w = mc(x);
I get 0.7854, which is pi/4 and the method does a perfect job, but if I add some noise
xnew = x+0.5*randn(size(t));
plot(xnew)
w = mc(xnew);
then the estimate is way off.
Why not use the periodogram, which will get the frequency correct for your sunspot data?
[Pxx,F] = periodogram(ssn,rectwin(length(ssn)),length(ssn),1);
[~,idx] = max(Pxx);
F(idx)
  댓글 수: 1
modified covariance
modified covariance 2012년 11월 2일
편집: modified covariance 2012년 11월 2일
thank you Wayne King, the periodogram u suggested certainly gets the answer which is 0.0076.
unfortunately, i must have to use the following code
load spot_num.txt
ssn = spot_num(:,3);
ssn = ssn-mean(ssn);
together with MC estimator function to get the frequency "As Required by Assignment Guidelines"...
but anyway, thx a lot!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by