Clear Filters
Clear Filters

Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Current function value: NaN

1 view (last 30 days)
While using fminsearch I am getting the following error
Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: NaN
I am trying to maximise an utility function.
I will provide the code below.
function [utility] = demo(a,initx,b,q,nyears,alpha,beta,discount)
%define output variable x
%b = 0.42;
%initx = 0.0;
%q =2;
%alpha = 0.4
%beta = 0.08;
%discount = 0.98;
%nyears =100;
x = Lakemodel(initx,b,q,a,nyears);
v = zeros(nyears,1);
% Code for Lakemodel you can run it as a different function
%function [x,source,sink] = Lakemodel(initx,b,q,a,nyears)
%define output variable x
%x = zeros(nyears,1);
%x(1) = initx;
%for t = 2 : nyears%
%x(t) = x(t-1) + (a(t-1)) - b*x(t-1) + x(t-1)^q/(x(t-1))^q+1;
%end
%end
for t = 1:nyears
v(t) = discount^t*(alpha*a(t)-beta*x(t)*x(t));
end
utility = sum(v(:,1));
utility = utility*-1;

Answers (0)

Categories

Find more on Optimization 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!