Evaluate gradient for nth variables
Afficher commentaires plus anciens
Hi I have a script where the user enters a function f(x,y,...) and an initial value vector "X0" with length "n" where n is equal to the number of function variables. After that a variable "grad" is created as grad=gradient(f). I want to calculate grad at this initial value vector but it is not working. f(x,y,...) is symbolic, grad is symbolic and X0 is integer. Anyone can help? I know its a newbie question but it happens....
f(x1,x2)=x1^2-3*x1*x2+4*x2^2+x1-x2;
X0=[2;2];
i=length(X0);
ans=eval(grad(X0(1:i))) -----------Here is the problem
1 commentaire
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Symbolic Math Toolbox 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!