![]() |
[求助]kruskal程序出现的“下标出现非正整数”问题
我用的是matlab6.5,下面是我的kruskal程序:
b=input('please input the matrix of distance,b='); n=input('please input the number of points,n='); m=size(b,2); [B,i]=sortrows(b',3); B=B'; e=0;T=[]; k=0;t=1:n; for i=1:m; if t(B(1,i))~=t(B(2,i)); T(1:2,k)=B(1:2,i);c=c+B(3,i); k=k+1; tmin=min(t(B(1,i)),t(B(2,i))); tmax=max(t(B(1,i)),t(B(2,i))); for j=1:n; if t(j)==tmax; t(j)==tmin; end end end if k==n-1; break; end end T c 结果出现了这样的错误, ??? Subscript indices must either be real positive integers or logicals. 请问高手,这个要怎么改呢…… |
b或者n应该为整数,
b=int32(b); n=int32(n); 因为matlab默认的输入数都为double,而在对于数组的标志时,必须为整数. |
所有时间均为北京时间。现在的时间是 03:16。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.