|
> x'=integral(x*y(x).dx)/integral(y(x).dx) % Equation 10.25 where y(x) is the spectral density and x is the angular frequency.
> sum[x*y(x)] for the given values of x and y (ie a weighted form ). therefore I have
>
> numerator=x.*y;
>
> the bottom is the integral so i tried using the matlab function trapz(x,y) to calculate that as well.
>
> denominator =trapz(x,y);
>
You are essentially there, but not quite. Good work so far.
This is the formula you provide: x'=integral(x*y(x).dx)/integral(y(x).dx)
Then you need to convert it to Matlab, and you got the first part right:
integral(x*y) = sum(x.*y)
The second part is just as easy:
integral(y) = sum(y).
Therefore, your mean frequency (x) is simply:
meanX = sum(x.*y)/sum(y)
|