use modified covariance (MC) method to estimate frquency?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
let x(t)=10cos(200*pi*t+1.2) which is a continuous-time sinusoid. The x(t) is sampled every Ts=0.001 sec. to obtain a sequence x[n] where x[n]=x(nTs) for n between 0 and 100 (including 0 and 100)
how can I use modified covariance (MC) method, given the following code, to determine the frquency estimate for x[n].
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);
btw, What is purpose of setting r to 1 and -1 when its value is larger than 1 and smaller than -1,respectively?
thank u in advance.
0 Commenti
Risposta accettata
Wayne King
il 23 Ott 2012
Modificato: Wayne King
il 23 Ott 2012
I'm not familiar with this algorithm for frequency estimation. When I use the term "modified covariance method", it's in the context of autoregressive spectral estimation, but having said that it seems to work here.
t = 0:0.001:0.1-0.001;
x = 10*cos(200*pi*t+1.2); %although this signal is not corrupted by noise
w = mc(x);
returns 0.6283 radians/sample, that is equivalent to 628.3 radians/second which is 100 Hz (the frequency of the input sinusoid in cycles/second).
To answer your final question, the real-valued cosine function takes values between [-1,1]. If you take the inverse cosine of values in the interval [-1,1], you will get a real-valued output. However, if you take the inverse cosine of a value larger than 1, or smaller than -1, you will get a complex-valued output. The complex-valued cosine is not bounded by 1.
The code is ensuring that you do not input any values to acos() outside the interval [-1,1], so that the output is real-valued.
To use the function, mc.m, save the file in a folder on the MATLAB path and you can run it from the command line. For example, if you have the file in a folder called c:\mfiles, use
>>addpath 'c:\mfiles'
to add that folder. or you can use
>>pathtool
5 Commenti
Wayne King
il 23 Ott 2012
Modificato: Wayne King
il 23 Ott 2012
it returns 0.8388 as expected, you can just copy and paste the following to see this:
t = 0:0.001:0.1-0.001;
x = 10*cos(267*pi*t+1.2);
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)
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!