Problem using Hessian function

5 ビュー (過去 30 日間)
Prachi  Singh
Prachi Singh 2016 年 7 月 7 日
回答済み: Walter Roberson 2016 年 7 月 7 日
Hi ,
I am trying to calculate the hessian of the following function :
---------------
function logl = tryseven(p, xdata, ydata)
a = p(1);
b = p(2);
f = p(3);
g = p(4);
h = size(xdata,2)*log(a);
i = size(xdata,2)*log(b);
j = (b-1)*(log(ydata - f - g*xdata));
k = a*((ydata - f - g*xdata).^b);
logl = [-sum(j(:)) + sum(k(:) -h -i)];
end
--------------------
I run the following command , by providing the point at which Hessian has to be calculated:
--------------------
p(1) = 0.5272;
p(2) = 1.2401;
p(3) = -0.5815;
p(4) = 14.2491;
[hess,err]=hessian(@(p) tryseven(p, xdata, ydata))
-----------------------
But I am getting an error "Not enough input arguments."
Can somebody please tell me what error I have committed? I have attached my data.
Regards,
Prachi

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 7 月 7 日
Are you trying to use Symbolic Toolbox hessian() ? If so then it requires a symbolic function or symbolic expression first argument, an requires a vector of symbolic names as a second argument.
If you are trying to use This File Exchange Contribution then a scalar function first argument is fine, but the second argument needs to be the location to evaluate the Hessian at.

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by