幂律图画图2

% 2015年6月30日13时14分10秒——幂律图

clear

tic

%察看当前目录有多个log文件,将当前文件信息取到files 数据结构中。

filesShiJian=dir( '*.log' );

%  !!!注意这个地方要保证文件一定要顺序读入!!!最后要检查这个地方。

numberOfFiles=size( filesShiJian,1 );

% % 开始之前删除,这个数据文件,加一个判断,如果没有这个文件,则不删除。防止不断地向out3.dat文件加入数据。

% % delete('../mytests/*.mat')

%

% filesdata=dir( '*.dat' );

% numberdatafile = size( filesdata,1 );

% if numberdatafile > 0

%    delete('*.dat')

% end

% 读入数据。

for i = 1 : numberOfFiles

    % M 为时间点的数据

    M = csvread( filesShiJian(i).name );




%    x = 1 : 1 : length( M ) ;

%

%

%    % 画图,每个事件对应发生的时间。

%    figure

%    bar(x,M)

%   

%    % 设置Y轴坐标刻度

% %    set(gca,'YTick',[0,1])

%   

%    % 保存图像

%    str = [ 'out2'  filesShiJian(i).name  '.fig'] ;

%    saveas(gcf,str);

%    str = [ 'out2'  filesShiJian(i).name  '.jpg'];

%    saveas(gcf,str) ;

        % 计算间隔时间对应发生的频率——hk 为频率计数

        hk = zeros (1,length(M));

        % 统计每个相同的数值 有多少个,hk为计数器

        for j=1:length(M)

            for k=1:length(M)

                if M(j,1)== M(k,1)

                    hk(1,k)=hk(1,j)+1 ;

                end

            end

        end

        % c 为频率表

        a = [M';hk];

        b=a';

        % [C, ia, ic] = unique(b,'rows');

        c= unique(b,'rows');

        %

        x=c(:,1);

        ytemp=c(:,2);

        tempsum = sum(ytemp);

        y = ytemp / tempsum;

        figure()

        loglog(x,y,'*')


    str = [ 'out3MiLV'  filesShiJian(i).name  '.fig'] ;

    saveas(gcf,str);

    str = [ 'out3MiLV'  filesShiJian(i).name  '.jpg'];

    saveas(gcf,str) ;

disp ( num2str(i))  ;

toc

end

disp('******************************************************')

disp('over! over!          程序运行结束          over! over! ')

disp('******************************************************')

% % c 为频率表

% a = [M';hk];

% b=a';

%

% % [C, ia, ic] = unique(b,'rows');

% c= unique(b,'rows');

%

% %

% x=c(:,1);

% ytemp=c(:,2);

%

% tempsum = sum(ytemp);

% y = ytemp / tempsum;

%

% figure(3)

% loglog(x,y,'*')

%

% % ******************************************************

% % 如何在figure 4 上面,加入斜率 wyzprc——log10 ????

% figure(4)

% loglog(x,y,'k*')

% hold on

%

% % b是幂指数。

% [b,bint] = regress (log10(y),log10(x));

% b;

% % 取一个,序号与内容不一样的点 dian

% %  下面,如何从数列中,这个dian

%

% zhiShu = 1:length(x);

% dian = 1;

%

% for i=1:length(x)

%

% if zhiShu(i)~= x(i)

%

% dian=i-1;

%

% break;

%

% end

%

% end

%

% xx = [1:dian];

% xx = xx';

% yy = y(1:dian);

%

% polyn=polyfit(log10(xx),log10(yy), 1)

%

% k=polyn( 1 )%/polyn(2)

%

% % 常数项转化

%

% changShu = 10^(polyn(2))   

%

%

% x2=1:100; 

%

%

% y2 = changShu * x2.^ (k) ;

%

% plot(x2,y2,'k','linewidth',2.5) 

%

% hold on;

%

% title(['Slope = ',num2str(k)]);

%

% hold on;

%

% xlabel('\tau/minute');

%

% ylabel('P(\tau)');

%

% legend('data',' fitting');

%

% hold off

%

%

%

%

% % % % % 求拟合直线的参数一次项和常数项,以下画图填加 拟合曲线,已经成功,只是不象。

% % % % p =polyfit(log10(x),log10(y),1)

% % % %

%

%

%

%

%

%

% %  *****************************************************

% % 计算活跃度,活跃度为每个人一年共计发过多少的帖子。

%

% %  *****************************************************

% % 计算 阵发性

%

% mean_jianGe = mean (jianGe);

% std_jianGe = std(jianGe);

% zhenFa = (std_jianGe - mean_jianGe)/(std_jianGe + mean_jianGe)

%

% %  *****************************************************

% % 计算 记忆性 jiYi

% he_n1 = ones (1,length(jianGe)-1);

% he_n2 = he_n1;

%

% for i = 1 : length(jianGe)-1

%    he_n1(1,i) = jianGe(i,1);

%    he_n2(1,i) = jianGe(i+1,1);

% end

%

% mean_he1= mean(he_n1);

% mean_he2= mean(he_n2);

% std_he1 = std(he_n1);

% std_he2 = std(he_n2);

%

% jiYi= 0 ;

%

% for i = 1 : length(jianGe)-1

%   

%    jiYi = jiYi + ((jianGe(i)-mean_he1))-((jianGe(i)-mean_he2)) / std_he1 / std_he2;

%   

% end

%

%  jiYi = jiYi / (length(jianGe)-1)

%

% toc

%

你可能感兴趣的:(幂律图画图2)