Not enough input arguments.

조회 수: 4 (최근 30일)
Dursman Mchabe
Dursman Mchabe 2018년 12월 23일
댓글: Dursman Mchabe 2018년 12월 23일
Hi Everyone,
I have a user-defined code that is based on Euler method, that runs successfully. However the output does not compare satisfactority with the experiment for one variable. I would like to use fminsearch to estimate the parameters that can improve the fitting. However, when I try that I get the error message that states:
Error using fzero (line 306)
FZERO cannot continue because user-supplied function_handle ==> HionpH failed with the error below.
Not enough input arguments.
Error in ParametersFittingEulerMethodWater>EulerMethod (line 131)
pH = fzero(@HionpH, pH1);
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
Error in ParametersFittingEulerMethodWater (line 58)
[b, Results] = fminsearch(@EulerMethod,b);
I can not figure out which arguments are outstanding.
I have attached both the running code and the faulty code.
Please help

채택된 답변

Stephen23
Stephen23 2018년 12월 23일
편집: Stephen23 2018년 12월 23일
You defined the function HiopH with two input arguments:
function ph = HionpH (pH,b)
In earlier threads we helped you to parameterize it so that you could use fzero to find the pH value:
fzero(@(pH)HionpH(pH,b),pH_trial);
But now you tried to supply it to fzero again, without parameterizing it:
pH = fzero(@HionpH, pH1);
Do you notice the difference? HionpH requires two input arguments. fzero provides exactly one input argument. When fzero calls that function handle (of HionpH), does it provide the second input argument? (hint: no, it only provides one input argument). Thus the error.
  댓글 수: 1
Dursman Mchabe
Dursman Mchabe 2018년 12월 23일
Thanks a lot Stephen. I realised those mistakes and rectified them.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by