如何在函数中传递变化的变量?
以下是我想实现惩罚函数的源程序:function =obstacle_fun(x)
m=(1/2)^k;
g1 = x(1)-1;
g2 = x(2);
f = (1/12)*(x(1)+1)^3+x(2) + m*internal_penalty_fun(x);
g(1) = (1/4)*(x(1)+1)^2 - m/((x(1)-1)^2);
g(2) = 1 - m/(x(2)^2);
function =internal_penalty_result(x)
options=optimset('GradObj','on');
t=0.9;
k=1;
while (1/2)^k*internal_penalty_fun(x)>t
=fminunc(@obstacle_fun,x,options);
k=k+1;
x=x;
end
如何把internal_penalty_result(x)函数while循环中变化的k值
直接传递到函数obstacle_fun(x)中?
有劳各位大虾了!非常感谢!
页:
[1]