Mathematical formula of a function
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a Matlab function created based on the Chi Square Periodogram from Sokolove and Bushell, but with some modifications:
x = [4054,0,237,2009,4001,...,906,851,1134,3688]
passo = 1 % Step
freqmin = 1200 % Minimum Frequency
freqmax = 1600 % Maximum Frequency
aux=1;
% Goes from the min frequency to the max frequency, alternating by the step
for j=freqmin:passo:freqmax
% Creates a matrix based on the current frequency
for i=1:length(x)/j
if i==1
d(1,:)=x(i:i*j);
else
d(i,:)=x(((i-1)*j)+1:i*j);
end
end
% Converts the matrix to a vector and calculates the average
[row,col]=size(d);
tt=reshape(d,1,row*col);
xmedia=nanmean(tt);
% (Mh-M)^2
xaux=(tt-xmedia).^2;
% The denominator will be the average of the previous vector (xaux)
denominador=nanmean(xaux);
% Calculates an average of each column in the matrix and creates a vector with its results
daux= nanmean(d,1);
% ((Xi-M)^2) / N
dnumerador= nansum((daux-xmedia).^2)/length(faux);
% Calculates the Qp of the current frequency
Qp(aux)=dnumerador/denominador;
xAxis(aux)=j
aux=aux+1;
clear d
end
Can someone confirm to me if the following mathematical formula is correct and represents the function?
p = Current period length
N = Data length
Xi = Current data
M = Average of all data
Mh = Each data of the current period
Note: maybe this is not the right place to ask that but I really need to confirm that.
回答(1 个)
Star Strider
2016-8-6
编辑:Stephen23
2016-8-7
It would help to know what the variables are. It looks like ‘Qp’ is a ratio of variances, but beyond that I’ve not a clue. I have no idea how it relates to your code, because you have not documented any of it.
Is there a context we should know?
2 个评论
Star Strider
2016-8-6
The easiest way to determine if your code is correct is if the result of your calculation is the same as that produced by the software.
The equation is straightforward to implement (your software calculates it automatically), but I have no idea what your data are, their format, or what you’re doing with them. Without that, I can’t determine if your code is correct or not.
I duplicated and expanded on the link in a separate comment to your original post.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!