How to find the derivative without using a symbolic function in Matlab -
i find derivative of function:
function [f] = f4(x) f=0.5*(x(1)^2+10*x(2)^2); end i'm using symbols find jacobian:
x = sym('x', [2 1]); f=0.5*(x(1)^2+10*x(2)^2); grad=jacobian(f,x) which returns
grad = [ x1, 10*x2] then change manually can use feval:
grad = [ x(1,1), 10*x(2,1)]; i find using feval faster using subs. find derivative of function can evaluate using feval , avoid doing manually.
Comments
Post a Comment