![]() |
大家帮忙看一下我这段代码错在哪里
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); 麻烦大家帮忙看一下错在那里,谢谢了 |
所有时间均为北京时间。现在的时间是 06:30。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.