How to use dlgradient for computing second derivative?
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!