problem with fminunc: why the returned gradient is not a vector
古いコメントを表示
Hi, I am using the fminunc to find a minimum of a multivariable function f(x), where x is a vector. I want to know the value of the gradient at the solution x. So I type "[x,grad] = fminunc(fun,x0)" to get the gradient. However, the returned gradient is a scalar instead of a vector. I think the gradient should be a vector since my x is a vector. Could somebody explain it for me? Thanks!
回答 (1 件)
Mischa Kim
2014 年 3 月 4 日
編集済み: Mischa Kim
2014 年 3 月 4 日
Chuoxin, have you set
options = optimset('GradObj','on') % gradient outputted as 2nd argument
[x,fval,exitflag,output,grad] = fminunc(...) % gradient is 5th argument
1 件のコメント
Matt J
2014 年 3 月 4 日
The gradient should always be returned in the 5th output argument, even when GradObj option is used.
カテゴリ
ヘルプ センター および File Exchange で Mathematics and Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!