problem with the fminsearch function
Show older comments
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
Answers (1)
fminsearch assumes your objective function has a single input argument
[xy,z] = fminsearch(@(xy) gw(xy(1),xy(2)),[4,5])
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!