Input Argument Undefined for Passing a Parameter to a Function
Afficher commentaires plus anciens
Hello,
I apologize if I am asking a very simple question but it's been something that I have been trying to work out and so far have been unsuccesful.
I am trying to write code to employ the gradient descent method on the camel function. Displayed below is the code:
Gradient Descent:
function [ dx ] = grad_d(v,f,gamma )
[Fx, Gx, Hx]= f(v);
dx = A - gamma*Gx;
end
In this case I want to use the function 'camel':
function [ Fx, Gx, Hx ] = camel(vec)
V = num2cell(vec);
[x,y] = V{:};
Fx = 2*x^2 - 1.05*x^4 + (x^6/6) + x*y+y^2;
Gx = [ x^5 - (21/5)*x^3 + 4*x + y;
x+2*y];
Hx = [ 5*x^4 - (63/5)*x^2 + 4, 1;
1, 2];
end
When I try to run one evaluation with the above code I get the error below:
I run the code as follows:
vec = ones(2,1)
grad_d(vec,camel,.1)
and receive the following:
_Input argument "vec" is undefined._
I know that I am overlooking something small but I can't pin it down. Any help would be much appreciated.
Thank you,
Réponse acceptée
Plus de réponses (1)
Peter
le 16 Fév 2015
Catégories
En savoir plus sur Language Fundamentals 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!