Maximum number of function evaluations has been exceeded - increase MaxFunEvals option.
208 次查看(过去 30 天)
显示 更早的评论
Dear Matlab users: I've got a following problem: I try to find parameters of this function:
by simplex method (see the following code)
format compact
format long
xdata = [0.000,0.200,0.400,0.600,0.800,1.000,1.200,1.400,1.600,1.800,2.000,2.200,2.400,2.600,2.800,3.000,3.200,3.400,3.600,3.800,4.000,4.200,4.400,4.600,4.800,5.000];
ydata = [0.007,0.041,0.165,0.449,0.816,0.982,0.741,0.212,-0.362,-0.808,-0.975,-0.774,-0.290,0.290,0.775,0.982,0.849,0.527,0.237,0.077,0.018,0.003,0.000,0.000,0.000,0.000];
%Function to calculate the sum of residuals for our a given parameters
fun= @(p) sum(ydata - (-1*(p(1)-p(2)*(((xdata)-p(3))).^4).*(exp(-1*p(4)*((xdata)-p(3)).^2))).^2);
%starting guess for our parameters
%starting guess
pguess = [1.0,12.0,1.0,2.0];
%optimise
[p,fminres] = fminsearch(fun,pguess)
Unfortunately it doesn't work very well because this type of message appears:
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -Inf
I know that parameters, should be cca a= 1.0; b=12; c=2.4 and r=1.02 (in code, abcr parameters are p(1)...(p4)).
I need to use simplex method for iteration, so I try to fix this problem, but I am totaly newbie in matlab and don't know how to fix it.
Does anybody have any suggestion??
Thanks
Paul
0 个评论
回答(2 个)
Matt J
2014-8-7
Using the optimset command you can change MaxFunEvals and other algorithm parameters of fminsearch. You can also use optimoptions if you have the Optimization Toolbox.
2 个评论
Alan Weiss
2014-8-7
You cannot use optimoptions for fminsearch, you have to use optimset. For example,
options = optimset('MaxFunEvals',1000);
[p,fminres] = fminsearch(fun,pguess,options)
Alan Weiss
MATLAB mathematical toolbox documentation
mura0087
2021-1-20
I have this same problem! Even if I change MaxFunEvals to a very high number (1e30) I still get an Inf value out of fminsearch.
4 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!