Input Argument Undefined for Passing a Parameter to a Function
显示 更早的评论
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,
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Language Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!