有没有高手能帮我找下matlab程序的错误啊?Function ta=echotsp(w)w=[0 10 16 4 0 0 9 0 0 15 0 0;10 0 8 8 6 0 0 12 7 0 0 0;16 8 0 0 0 3 0 0 8 0 0 0;4 8 0 0 5 0 7 0 0 0 14 0;0 6 0 5 0 0 0 8 0 0 11 0;0 0 3 0 0 0 0 0 5 0 0 11;9 0 0 7 0 0 0 0 0
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 05:16:47
有没有高手能帮我找下matlab程序的错误啊?Function ta=echotsp(w)w=[0 10 16 4 0 0 9 0 0 15 0 0;10 0 8 8 6 0 0 12 7 0 0 0;16 8 0 0 0 3 0 0 8 0 0 0;4 8 0 0 5 0 7 0 0 0 14 0;0 6 0 5 0 0 0 8 0 0 11 0;0 0 3 0 0 0 0 0 5 0 0 11;9 0 0 7 0 0 0 0 0
有没有高手能帮我找下matlab程序的错误啊?
Function ta=echotsp(w)
w=[0 10 16 4 0 0 9 0 0 15 0 0;10 0 8 8 6 0 0 12 7 0 0 0;
16 8 0 0 0 3 0 0 8 0 0 0;4 8 0 0 5 0 7 0 0 0 14 0;
0 6 0 5 0 0 0 8 0 0 11 0;0 0 3 0 0 0 0 0 5 0 0 11;
9 0 0 7 0 0 0 0 0 6 9 0;0 12 0 0 8 0 0 0 8 0 4 8;
0 7 8 0 0 5 0 8 0 0 0 8;15 0 0 0 0 0 6 0 0 0 7 0;
0 0 0 14 11 0 9 4 0 7 0 8 ;0 0 0 0 0 11 0 8 8 0 8 0]
[m,n]=size(w);
U=4.5;dE=1;start=1;
[i,jj]=find(w(start,:));
m=zeros(length(jj),n);
for l=1;length(jj)
m(l,start)=1;Y{l}=zeros(n);
E{l}=zeros(n);
E{l}(start,jj(l))=w(start.jj(l));
nxtf{l}(1)=jj(l);lstf{l}(1)=start;
I{l}=zeros(n);
end
l1=ones(1,length(jj))*2;
mc=zeros(1,length(jj));
B=0;
f{n}=[];
while all(mc~=n)
if B==1
nlE=length(E);
for fE=1:length(E)
Yt=Y{fE};mt=m(fE,:);It=I{fE};
ft=f{fE};Et=E{fE};nxtft=nxtf{fE};
lstft=lstf{fE};
for k=1:length(f{fE})
[i,j]=find(w(f{fE}(k),:));
for l=1:length(j)
if m(fE,j(l))~=1
if =1
nlE=nlE+1; Y{nlE}=Yt;
m(nlE,:)=mt; I{nlE}=It;
f{nlE}=ft; nxtf{nlE}=nxtft;
lstf{nlE}=lstft; l1(nlE)=2;
nxtf{nlE}(l1(nlE))=j(l);
E{nlE}(f{fE}(k),nxtf{nlE}(l1(nlE)))=I{fE}(f{fE}(k))+w(f{fE}(k),nxtf{nlE}(l1(nlE)));
lstf{nlE}(l1(nlE))=f{fE}(k);
l1(nlE)=l1(nlE)+1;
else
nxtf{fE}(l1(fE))=j(1);
E{fE}(f{fE}(k),nxtf{fE}(l1(fE)))=I{fE}(f{fE}(k))+w(f{fE}(k),nxtf{fE}(l1(fE)));
lstf{fE}(l1(fE))=f{fE}(k);
l1(fE)=l1(fE)(k);
l1(fE)=l1(fE)+1;
end
else
E{fE}(f{fE}(k),j(1))=inf;
end
end
end
end
B=0;
clear f; f{fE}=[ ];
else if B==0
for lE=1:length(E)
fN=1;
for t=1:length(nxtf{lE})
if m(lE,nxtf{lE}(t))~=1;
if U>=E{lE}(lstf{lE}(t),nxtf{lE}(t))
Y{lE}(lstf{lE}(t),nxtf{lE}(t))=1;
m(lE,nxtf{lE}(t))=1;
I{lE}(nxtf{lE}(t))=I{lE}(lstf{lE}(t))+w(lstf{lE}(t),nxtf{lE}(t));
f{lE}(fN)=nxtf{lE}(t);
fN=fN+1;
B=1;
end
end
end
end
for fc=1:length(E)
mc(fc)=sum(m(fc,:));
end
for fc=1:length(E)
mc(fc)=sum(m(fc,:));
end
U=U+dE;
end
end
a=find(mc==n);
for i=1:length(a)
ta{i}=traversal(Y{a(i)},start)
end
有没有高手能帮我找下matlab程序的错误啊?Function ta=echotsp(w)w=[0 10 16 4 0 0 9 0 0 15 0 0;10 0 8 8 6 0 0 12 7 0 0 0;16 8 0 0 0 3 0 0 8 0 0 0;4 8 0 0 5 0 7 0 0 0 14 0;0 6 0 5 0 0 0 8 0 0 11 0;0 0 3 0 0 0 0 0 5 0 0 11;9 0 0 7 0 0 0 0 0
for l=1;length(jj)
应该是:,不是分号
最好是一步一步执行找错吧