I cannot figure out how to increase the max iterations of the function. I am pretty new at this. I have three conditions of reaction time (Compatible, Incompatible and none)

3 vues (au cours des 30 derniers jours)
%Sample Script from tool box egfit%
function R=egfit(data, params, options) % versio2.2 27/02/07 % uses fmin nsearch instead of fmins % (c) Yves Lacouture, Universite Laval
[n,m]=size(data); if min(n,m) > 1 error('First argument must be a vector'); end if n == 1 %case of a row vector of data data = data'; n = m; end if min(data)<=0 % get rid of zeros and negative numbers warning('data include zero(s) and/or negative number(s)'); nc=length(find(data<=0)); fprintf('%d values out of %d are truncated\n', nc, n); data=data(find(data>0)); end if (nargin > 1 & ~isempty(params)) % explicit starting parameter values set by user mu=params(1); sig=params(2); tau=params(3); else tau=std(data).*0.8; % set defaut starting parameter values if not explicit mu=mean(data)-tau; % uses heuristic values sig=sqrt(var(data)-(tau^2)); end if (nargin > 2 & ~isempty(options)) % explicit options values set by user and pass to fmins opts(1:3)=options(1:3) % termination, function tolerances and maximum number of iterations else opts=[ 1.e-4,1.e-4]; % default values for termination and function tolerances opts(3)=400*length(data); % default max number of iterations end
%optionsfmin=optimset('TolX',opts(1),'TolFun',opts(2),'MaxIter',opts(3)); % was in version 2.2; should be MaxFunEvals
optionsfmin=optimset('TolX',opts(1),'TolFun',opts(2),'MaxFunEvals',opts(3));
pinit = [mu sig tau]; % put initial parameter values in an array
% [R,opt] = fmins('eglike',pinit,opts,[],data); % based on old function fmins [R,fval,outf,op]=fminsearch(@(params) eglike(params,data),pinit,optionsfmin);
if (outf<1) disp(op) end
Here is an example of the problem that I am encountering from my command window:
"Exgaussianfunction=egfit('VarName3')
Exiting: Maximum number of iterations has been exceeded
- increase MaxIter option.
Current function value: -Inf
iterations: 600
funcCount: 2802
algorithm: 'Nelder-Mead simplex direct search'
message: 'Exiting: Maximum number of iterations has been exceeded…'
exgaussianfunction =
91.0638 18.7645 0.5234"
  1 commentaire
Alan Weiss
Alan Weiss le 8 Déc 2015
Please mark your code with the {} Code button so that we can read it more easily.
Alan Weiss
MATLAB mathematical toolbox documentation

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by