我用的是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.
请问高手,这个要怎么改呢……