Problem using Hessian function

5 visualizaciones (últimos 30 días)
Prachi  Singh
Prachi Singh el 7 de Jul. de 2016
Respondida: Walter Roberson el 7 de Jul. de 2016
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

Respuestas (1)

Walter Roberson
Walter Roberson el 7 de Jul. de 2016
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by