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일

0 개 추천

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월 27일

편집:

2017년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by