LINGO错误,这段程序为什么会出现以下错误:
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/23 19:13:17
LINGO错误,这段程序为什么会出现以下错误:
程序:
clc;clear;
M=1000;
a(1,2)=8; a(1,3)=5;
a(1,4)=9;a(1,5)=12;
a(1,6)=14;a(1,7)=12;
a(1,8)=16;a(1,9)=17;
a(1,10)=22;
a(2,3)=9; a(2,4)=15;
a(2,5)=17;a(2,6)=8;
a(2,7)=11;a(2,8)=18;
a(2,9)=14;a(2,10)=22;
a(3,4)=7;a(3,5)=9;
a(3,6)=11;a(3,7)=7;
a(3,8)=12;a(3,9)=12;
a(3,10)=17;
a(4,5)=3; a(4,6)=17;a(4,7)=10;
a(4,8)=7;a(4,9)=15;a(4,10)=18;
a(5,6)=8;a(5,7)=10;a(5,8)=6;
a(5,9)=15;a(5,10)=15;
a(6,7)=9;a(6,8)=14;a(6,9)=8;
a(6,10)=16;
a(7,8)=8;a(7,9)=6;a(7,10)=11;
a(8,9)=11;a(8,10)=11;
a(9,10)=10;
a=[a;zeros(1,10)];
a=a+a';a(find(a==0))=M;
result=[];p=1;tb=2:length(a);
while length(result)~=length(a)-1
temp=a(p,tb);temp=temp(:);
d=min(temp);
[jb,kb]=find(a(p,tb)==d);
j=p(jb(1));k=tb(kb(1));
result=[result,[j;k;d]];p=[p,k];tb(find(tb==k))=[];
end
result
程序:
clc;clear;
M=1000;
a(1,2)=8; a(1,3)=5;
a(1,4)=9;a(1,5)=12;
a(1,6)=14;a(1,7)=12;
a(1,8)=16;a(1,9)=17;
a(1,10)=22;
a(2,3)=9; a(2,4)=15;
a(2,5)=17;a(2,6)=8;
a(2,7)=11;a(2,8)=18;
a(2,9)=14;a(2,10)=22;
a(3,4)=7;a(3,5)=9;
a(3,6)=11;a(3,7)=7;
a(3,8)=12;a(3,9)=12;
a(3,10)=17;
a(4,5)=3; a(4,6)=17;a(4,7)=10;
a(4,8)=7;a(4,9)=15;a(4,10)=18;
a(5,6)=8;a(5,7)=10;a(5,8)=6;
a(5,9)=15;a(5,10)=15;
a(6,7)=9;a(6,8)=14;a(6,9)=8;
a(6,10)=16;
a(7,8)=8;a(7,9)=6;a(7,10)=11;
a(8,9)=11;a(8,10)=11;
a(9,10)=10;
a=[a;zeros(1,10)];
a=a+a';a(find(a==0))=M;
result=[];p=1;tb=2:length(a);
while length(result)~=length(a)-1
temp=a(p,tb);temp=temp(:);
d=min(temp);
[jb,kb]=find(a(p,tb)==d);
j=p(jb(1));k=tb(kb(1));
result=[result,[j;k;d]];p=[p,k];tb(find(tb==k))=[];
end
result
你这是matalb的代码,你把它放到lingo里面运行当然会出错了,matlab的语法和lingo的语法是不一样的.
把代码拷到matlab里,加个回车就可以得到结果了
result =
1 3 4 5 3 7 1 5 9
3 4 5 8 7 9 2 6 10
5 7 3 6 7 6 8 8 10
把代码拷到matlab里,加个回车就可以得到结果了
result =
1 3 4 5 3 7 1 5 9
3 4 5 8 7 9 2 6 10
5 7 3 6 7 6 8 8 10