problem with the fminsearch function

gw = @(c,m) -((2.*m.*c)./(4 + 0.8.*m + c.^2 + 0.2.*m.^3));
[X,Y] = meshgrid(0:.5:10,0:.5:10);
Z = gw(X,Y);
surf(X,Y,Z,'EdgeColor','none')
[xy,z] = fminsearch(gw,[4,5])
and i get the error
Not enough input arguments.
Error in Homework_3>@(c,m)-((2.*m.*c)./(4+0.8.*m+c.^2+0.2.*m.^3))
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
Error in Homework_3 (line 79)
[xy,z] = fminsearch(gw,[4,5])
please help

回答(1 个)

Matt J
Matt J 2017-9-27
编辑:Matt J 2017-9-28
fminsearch assumes your objective function has a single input argument
[xy,z] = fminsearch(@(xy) gw(xy(1),xy(2)),[4,5])

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

标签

编辑:

2017-9-28

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by