Code covered by the BSD License  

Highlights from
Semi variance method and scaled windowed variance method for fractal time series analysis.

from Semi variance method and scaled windowed variance method for fractal time series analysis. by Guan Wenye
Semi variance method and scaled windowed variance method for fractal time series analysis.

D1=semivariance(DATA)
function D1=semivariance(DATA)
%the variable h1 can be changed to your interest
%if you don't change h1,the time series should be of length greater than 2500
%code by Guan Wenye,guanwenye@tju.edu.cn
h1=100:200:2000;
h1=h1';
N1=length(h1);
rh=zeros(N1,1);
n=1;
    for t1=100:200:2000
        rh1=sum((DATA(1:t1)-DATA((1+t1):(2*t1))).^2);
       rh(n)=rh1/2/t1;
       n=n+1;
    end
    plot(log(h1),log(rh),'*')
    hold on
     h2=polyfit(log(h1),log(rh),1);
     plot([log(h1(1)) log(h1(N1))],[polyval(h2,log(h1(1)))  polyval(h2,log(h1(N1)))],'r')
     D1=(4-h2(1))/2;

Contact us at files@mathworks.com