seuzw
2009-03-07, 17:24
for i=1:length(x)
if x(i,1)*x(i,2)-50>0
z(i)=0.25*(x(i,1)^2+x(i,2)^2)+2*x(i,1)*(1-x(i,2))+lamada*(x(i,1)+x(i,2)-50); lamada=z*lamada;
else z(i)=0.25*(x(i,1)^2+x(i,2)^2)+2*x(i,1)*(1-x(i,2));
end
end
其中:
lamada=100;
x是一个8*2的矩阵
x =
76.1802 77.5226
84.3212 13.8710
21.9207 47.6851
10.3580 56.0957
1.5363 0.5032
34.1422 91.7063
1.4914 91.6769
35.2252 28.2907
运行提示错误:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> gafun1 at 6
z(i)=0.25*(x(i,1)^2+x(i,2)^2)+2*x(i,1)*(1-x(i,2))+lamada*(x(i,1)+x(i,2)-50);
麻烦大家帮忙看一下错在那里,谢谢了
if x(i,1)*x(i,2)-50>0
z(i)=0.25*(x(i,1)^2+x(i,2)^2)+2*x(i,1)*(1-x(i,2))+lamada*(x(i,1)+x(i,2)-50); lamada=z*lamada;
else z(i)=0.25*(x(i,1)^2+x(i,2)^2)+2*x(i,1)*(1-x(i,2));
end
end
其中:
lamada=100;
x是一个8*2的矩阵
x =
76.1802 77.5226
84.3212 13.8710
21.9207 47.6851
10.3580 56.0957
1.5363 0.5032
34.1422 91.7063
1.4914 91.6769
35.2252 28.2907
运行提示错误:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> gafun1 at 6
z(i)=0.25*(x(i,1)^2+x(i,2)^2)+2*x(i,1)*(1-x(i,2))+lamada*(x(i,1)+x(i,2)-50);
麻烦大家帮忙看一下错在那里,谢谢了