声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 19086|回复: 97

[分形与混沌] 求助:计算关联维数的G-P算法

[复制链接]
发表于 2007-11-15 16:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
在下列的G_P算法中:

function [ln_r,ln_C]=G_P(data,N,tau,min_m,max_m,ss)
% the function is used to calculate correlation dimention with G-P algorithm
%   
计算关联维数的GP算法
% data:the time series                       时间序列
% N: the length of the time series           时间序列长度
% tau: the time delay                        时间延迟
% min_m:the least embedded dimention m       最小的嵌入维数
% max_m:the largest embedded dimention m     最大的嵌入维数
% ss:the stepsize of r                       r的步长
%skyhawk
for m=min_m:max_m
    Y=reconstitution(data,N,m,tau);%reconstitute state space
    M=N-(m-1)*tau;%the number of points in state space
    for i=1:M-1
        for j=i+1:M
            d(i,j)=max(abs(Y(:,i)-Y(:,j)));%calculate the distance of each two           
        end                                %points in state space  
计算状态空间中每两点之间的距离
    end
    max_d=max(max(d));%the max distance of all points   
得到所有点之间的最大距离
    d(1,1)=max_d;
    min_d=min(min(d));%the min distance of all points   
得到所有点间的最短距离
    delt=(max_d-min_d)/ss;%the stepsize of r            得到r的步长
    for k=1:ss
        r=min_d+k*delt;
        C(k)=correlation_integral(Y,M,r);%calculate the correlation integral
        ln_C(m,k)=log(C(k));%lnC(r)
        ln_r(m,k)=log(r);%lnr
        fprintf('%d/%d/%d/%d\n',k,ss,m,max_m);
    end
    plot(ln_r(m,:),ln_C(m,:));
    hold on;
end
fid=fopen('lnr.txt','w');
fprintf(fid,'%6.2f %6.2f\n',ln_r);
fclose(fid);
fid = fopen('lnC.txt','w');
fprintf(fid,'%6.2f %6.2f\n',ln_C);
fclose(fid);

运行不成
提示错误:Strings passed to EVAL cannot contain function declarations

俺是新手,刚刚学习分形与混沌,请大家多多帮助!!谢谢了!!
回复
分享到:

使用道具 举报

发表于 2007-11-15 18:33 | 显示全部楼层
首先,请给出你所用的参数定义,你给出的这个代码就是论坛里面现成的,对你所说的问题没有任何的参考价值!还请把问题说的清楚点哦!
 楼主| 发表于 2007-11-17 19:07 | 显示全部楼层
tau=9
min_m=2
max_m=12
ss=6
发表于 2007-11-18 20:17 | 显示全部楼层
请将错误提示完整贴出,最好能够给出数据组,这样可以帮你分析!
 楼主| 发表于 2007-11-22 09:00 | 显示全部楼层
现在运行不了
tau=9;ss=6
data=[193
96
324
333
3310
2240
2970
2490
3260
846
343
471
225
96
252
632
983
571
942
857
476
964
871
1350
1150
1410
258
174
99
163
32
1230
228
1480
646
3500
2080
613
4380
3020
2040
4730
1048
807
146
51
152
227
160
346
345
760
292
252
381
384
825
282
330
612
492
504
854
5650
1010
594
2400
1704
865
725
374
1956
406
353
1308
2610
2720
1063
133
197
132
128
121
134
1105
856
4164
2928
3210
3920
3480
3030
2180
2370
2870
2460
5050
2530
2840
1990
2590
2860
3120
4860]
N=length(data)
min_m=2;max_m=9
for m=min_m:max_m
    Y=reconstitution(data,N,m,tau);%reconstitute state space
    M=N-(m-1)*tau;%the number of points in state space
    for i=1:M-1
        for j=i+1:M
            d(i,j)=max(abs(Y(:,i)-Y(:,j)));%calculate the distance of each two           
        end                                %points in state space  计算状态空间中每两点之间的距离
    end
    max_d=max(max(d));%the max distance of all points   得到所有点之间的最大距离
    d(1,1)=max_d;
    min_d=min(min(d));%the min distance of all points   得到所有点间的最短距离
    delt=(max_d-min_d)/ss;%the stepsize of r            得到r的步长
    for k=1:ss
        r=min_d+k*delt;
        C(k)=correlation_integral(Y,M,r);%calculate the correlation integral
        ln_C(m,k)=log(C(k));%lnC(r)
        ln_r(m,k)=log(r);%lnr
        fprintf('%d/%d/%d/%d\n',k,ss,m,max_m);
    end
    plot(ln_r(m,:),ln_C(m,:));
    hold on;
end
fid=fopen('lnr.txt','w');
fprintf(fid,'%6.2f %6.2f\n',ln_r);
fclose(fid);
fid=fopen('lnC.txt','w');
fprintf(fid,'%6.2f %6.2f\n',ln_C);
fclose(fid)

谢谢了!!
发表于 2007-11-22 13:39 | 显示全部楼层
我帮你试过了,是可以算的,结果如下:
ln_r =
         0         0         0         0         0         0
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337
    6.8420    7.5351    7.9406    8.2283    8.4514    8.6337

ln_C =
         0         0         0         0         0         0
   -1.3106   -0.7425   -0.3090   -0.1297   -0.0353         0
   -1.8723   -1.0207   -0.4231   -0.1892   -0.0542         0
   -2.4842   -1.3415   -0.5572   -0.2685   -0.0796         0
   -3.0963   -1.7371   -0.7235   -0.3735   -0.1089         0
   -3.5530   -2.0742   -0.8642   -0.4427   -0.1283         0
   -3.9326   -2.4379   -1.0081   -0.5108   -0.1428         0
   -4.4067   -2.8381   -1.1563   -0.5673   -0.1683         0
   -5.1080   -3.2108   -1.2793   -0.6156   -0.1953         0

计算结果你可以自己用最小二乘拟合做的,就不给你算了

图示如下
untitled.jpg
 楼主| 发表于 2007-11-22 14:44 | 显示全部楼层
非常感谢!!我在试试。
 楼主| 发表于 2007-11-22 14:51 | 显示全部楼层
不好意思还我算不出,不知什么地方出错了,上面程序运行的结果是:
ss =
     6
data =
         193
          96
         324
         333
        3310
        2240
        2970
        2490
        3260
         846
         343
         471
         225
          96
         252
         632
         983
         571
         942
         857
         476
         964
         871
        1350
        1150
        1410
         258
         174
          99
         163
          32
        1230
         228
        1480
         646
        3500
        2080
         613
        4380
        3020
        2040
        4730
        1048
         807
         146
          51
         152
         227
         160
         346
         345
         760
         292
         252
         381
         384
         825
         282
         330
         612
         492
         504
         854
        5650
        1010
         594
        2400
        1704
         865
         725
         374
        1956
         406
         353
        1308
        2610
        2720
        1063
         133
         197
         132
         128
         121
         134
        1105
         856
        4164
        2928
        3210
        3920
        3480
        3030
        2180
        2370
        2870
        2460
        5050
        2530
        2840
        1990
        2590
        2860
        3120
        4860

N =
   104
max_m =
     9
??? Undefined function or variable 'reconstitution'.
发表于 2007-11-22 15:12 | 显示全部楼层
你没有reconstitution.m这个函数,可以在论坛搜索的到的,

另外,建议你去matlab主页下载混沌研究的工具箱,即Chaos toolbox V2.0,里面这些工具比较全面!
发表于 2007-11-22 17:14 | 显示全部楼层

回复 #8 kingsir 的帖子

这样的数据是不是要想办法处理一下,再发上来,看起来比较麻烦的
 楼主| 发表于 2007-11-22 19:31 | 显示全部楼层
回octopussheng :非常感谢!!
回无水1324 :以后注意
发表于 2007-11-22 21:18 | 显示全部楼层

回复 #11 kingsir 的帖子

你做的时候最好不要直接修改源程序,可以在命令行里面用命令的方式输入,源码其实都是一样的,直接调用就可以了,呵呵!
 楼主| 发表于 2007-11-23 10:33 | 显示全部楼层
主任:我在论坛没有搜到Chaos toolbox V2.0,beidu和google搜到的不能下载,能否发给我一个?
        email:ytht1210◎21cn.com
        谢谢你的无私帮助
??
发表于 2007-11-23 10:50 | 显示全部楼层
昨天好像给你发了,可能我的邮箱有问题吧,刚给你发了,查收一下吧!
 楼主| 发表于 2007-11-23 11:45 | 显示全部楼层
收到!谢谢了!有问题再向你请教!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-8 08:30 , Processed in 0.104395 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表