How to use dlgradient for computing second derivative?
Mostrar comentarios más antiguos
The following code gives me an error.
x0 = dlarray([-1,2]);
[fval,gradval] = dlfeval(@rosenbrock,x0)
function [y,dy2dx] = rosenbrock(x)
y = 100*(x(2) - x(1).^2).^2 + (1 - x(1)).^2;
dydx = dlgradient(y,x);
dy2dx= dlgradient(dydx,x);
end
I am using dlgradient to compute the second derivative but getting the following error:
"Error using dlfeval (line 43)
Value to differentiate must be a traced dlarray scalar."
Any help on what am i doing wrong? Thanks.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!