www.pudn.com > MF-DFA.rar > MF_DFA.m, change:2009-04-08,size:984b


 
lenSeg = 10; 
polyPower = 5; 
q = 2; 
%% remove DC component of all input data, dataInput shall be a row array 
load cc; 
dataInput = cc; 
meanInput = mean(dataInput); 
dataInputZero = dataInput - meanInput; 
lenInput = length(dataInput); 
%% divided into segments 
cntSegHalf = floor(lenInput/lenSeg); 
matrixInput1 = reshape(dataInputZero(1:lenSeg*cntSegHalf), lenSeg, cntSegHalf); 
matrixInput2 = reshape(dataInputZero(lenInput-lenSeg*cntSegHalf+1:lenInput), lenSeg, cntSegHalf); 
matrixInput = [matrixInput1,matrixInput2]; 
cntSeg = cntSegHalf*2; 
%% poly fit and calculate fit value for each collumn 
coefPoly = zeros(polyPower+1,cntSeg); 
valueFit = zeros(size(matrixInput)); 
for ii=1:cntSeg 
    coefPoly(:,ii) = polyfit([1:lenSeg]',matrixInput(:,ii),polyPower); 
    valueFit(:,ii) = polyval(coefPoly(:,ii),1:lenSeg); 
end 
%% calculate wave function 
diffMatrix = valueFit - matrixInput; 
diffMMSE = mean(diffMatrix.^2); 
FuncQs = (mean(diffMMSE.^(q/2)))^(1/q)

2018无需申请注册送58体验金