shuilan1984ly 发表于 2008-11-11 12:14

计算关联维时遇到的问题!

tau=9;ss=6;
data = [---省略---];
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);
大家帮忙看看,为什么到了end
    plot(ln_r(m,:),ln_C(m,:));
    hold on;
end
这一步就出现错误Undefined function or variable 'd'.
明明是定义了d啊!
请各位高手帮忙啊!

[ 本帖最后由 sigma665 于 2008-11-11 16:53 编辑 ]

xubin 发表于 2008-11-11 13:43

数据?

没有数据怎么便于帮你检查。

shuilan1984ly 发表于 2008-11-11 16:18

0.539589905
0.62942492
0.541100324
0.364385692
0.726098655
0.76503888
0.350448718
0.345463259
0.417826772
0.059067524
0.315777414
0.125562701
0.074241486
0.055517241
0.027329193
0.203525741
0.105401929
0.285198098
0.336062992
0.038396226
0.096384365
0.521884984
0.598346095
0.216837061
0.417821138
0.535605816
0.378103976
0.402092308
0.349152542
0.454915254
0.079970326
0.107425897
0.092779553
0.013129032
0.03265625
0.030870968
0.213841369
0.331534884
0.061875
0.027281399
0.023011094
0.037022654
0.084201954
0.126791277
0.182333333
0.009369085
0.114217252
0.055177994
0.160795107
0.078402458
0.047594554
0.07550702
0.000695103
0.016525822
0.002444444
0.000890688
0.221748808
0.052956381
0.057693523
0.010748092
0.020357143
0.019877489
0.01858679
0
0.466043614
0.215692771
0.421886228
0.458165138
0.29807571
0.039578606
0.151855346
0.39407767
0.333971743
0.463621795
0.381263823
0.279450382
0.460241327
0.538865031
0.020157978
0.102044025
0.105794118
1.145762712
0.002376543
0.361980831
0.584523077
0.703717949
0.715810147
0.5575625
0.549822866
0.219004525
0.499684543
0.320561622
0.71699842
0.409233083
0.379023622
0.645356577
0.498954248
0.371644042
0.141601256
0.335968992
0.415959119
0.194791667
0.528278041
0.619620253
0.478639241
0.469861963
0.736744186
0.37488408
0.313923077
0.36778626
0.765107362
1.338046875
0.779876161
0.532594937
0.375905512
0.75754717
0.707018927
0.518203125
0.604914197
0.098430141
0.073971519
0.689251592
0.42301092
0.748034591
0.46257716
0.195216049
0.730172414
0.388286164
0.787697161
0.51734375
0.480708661
0.61661743
0.487419872
0.622769231
0.627959502
1.079816514
0.525320513
0.653773585
0.863063764
0.456055901
0.500629921
0.271518987
0.484341085
0.190517241
0.534260731
0.733623418
0.32982866
0.832638889
0.424845201
0.426530612
0.61072
0.399919743
0.564593698
0.34546875
0.519968799
0.122705696
0.090677966
0.727639752
0.739921875
0.513276398
0.599761905
0.264285714
0.606807512
0.306877898
0.528463855
0.702580645
0.394937695
0.560610932
0.61908646
0.611399371
0.632242991
0.437114198
0.506418384
0.377315542
0.324247227
0.220518868
0.686862442
0.4503125
0.207098765
0.435669291
0.817840735
0.306340289
0.571187801
0.472203947
0.499516908
0.268103448
0.20485133
0.540546875
0.177586207
0.458623418
0.06637931
0.624882629
0.41271722
0.20312989
0.429508197
0.618223583
0.694332298
0.49984544
0.25851735
0.370077519
0.447196262
0.049292453
0.6
0.514544025
0.509904913
0.530141287
0.787068966
0.248191824
0.502570481
1.364783282
0.69609375
0.60911215
0.605345912
0.451415094
0.485396825
0.653178295
0.727308294
0.190517241
0.504453125
0.592109375
0.349605678
0.582810047
0.491221374
0.681317829
1.587917329
0.566936791
0.537893082
0.670175439
0.776886035
0.407636656
0.520504732
0.130870918
0.479731861
0.15628882
0.086124031
0.546540881
0.295689655
0.629188482
0.271978022
0.12433281
0.53436019
0.838012618
0.538828125
0.745023328
0.555205047
0.480926217
0.503521127
0.037185535
0.622275641
0.717429022
0.351267829
0.701724138
0.664330709
0.5225
0.565492958
0.479769231
0.490945513
0.750319489
0.697645212
0.532972136
0.488309637
0.415789474
0.449249249
1.223172628
0.822413793
0.504675119
0.53351735
0.03514377
0.605259027
0.30399361
0.17700157
0.477406832
0.431338583
0.365207006
0.342679128
0.109289176
0.415789474
0.416428571
0.303834116
0.357032457
0.090944882
0.355477308
0.577760252
0.173865415
0.124643423
0.559572785
0.201811024
0.337380192
0.154213938
0.373828125
0.36607717
0.535298742
0.16576507
0.308241758
0.679462875
0.471178344
0.193961353
0.142879499
0.088932496
0.407120501
0.196056782
0.278426791
谢谢啊

sigma665 发表于 2008-11-11 16:18

还是进入调试模式,一行一行运行

shuilan1984ly 发表于 2008-11-11 18:12

一行一行运行也不行啊!就命啊,到底错在哪里啊!

ch_j1985 发表于 2008-11-11 19:23

回复 楼主 shuilan1984ly 的帖子

数组d在开始时就应该定义长度吧
页: [1]
查看完整版本: 计算关联维时遇到的问题!