Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2009-03-04
年龄: 43
帖子: 1
声望力: 0 ![]() |
![]()
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); 麻烦大家帮忙看一下错在那里,谢谢了 |
![]() |
![]() |