loveyoudx
2012-03-15, 11:13
我m-file里写的是
function y=obj2(x)
% a function of 20 variables
%
temp=0;
for i=1:20
temp=temp+x(i)^2;
end
y=temp;
end
我想用trust region 来求最小值,但是在fminunc需要我提供gradient function, 对上面的function我应该怎么给他的gradient?谢谢!
function y=obj2(x)
% a function of 20 variables
%
temp=0;
for i=1:20
temp=temp+x(i)^2;
end
y=temp;
end
我想用trust region 来求最小值,但是在fminunc需要我提供gradient function, 对上面的function我应该怎么给他的gradient?谢谢!