Nonlinear fitting - No output function with MultiStart
Show older comments
I'm fitting a function to some nonlinear data. However, the output that I get is:
MultiStart with properties:
UseParallel: 0
Display: 'final'
FunctionTolerance: 1.0000e-06
MaxTime: Inf
OutputFcn: []
PlotFcn: []
StartPointsToRun: 'all'
XTolerance: 1.0000e-06
No plot and not output function.
This is the code:
% Parameters
p(1) = G_max_chl;
p(2) = G_max_glu;
p(3) = tau_rise_In;
p(4) = tau_decay_In;
p(5) = tau_rise_Ex;
p(6) = tau_decay_Ex;
% Create the objective function
fitfcn = @(p, Vm, EGlu, EChl, dt, tmax) ((p(1)) .* ((1 - exp(-(0:dt:tmax-dt) / p(3))) .* exp(-(0:dt:tmax-dt) / p(4))) * (Vm - EChl)) + ((p(2)) .* ((1 - exp(-(0:dt:tmax-dt) / p(5))) .* exp(-(0:dt:tmax-dt) / p(6))) * (Vm - EGlu));
% Create the training data
rng default % For reproducibility
N = 200; % Number of data points
preal = [80,15,0.44,0.73,15,3]; % Real coefficients
Vm = -30;
Eglu = 0;
EChl = -70;
dt = 0.1;
tmax = 120;
ydata = fitfcn(preal,xdata); % Response data with noise
ydata = awgn(ydata,35,'measured');
% Set bounds and initial point.
lb = [0,0,0,0,0,0];
ub = [150,150,5,5,20,20];
p0 = 5*ones(1,6); % Arbitrary initial points
% Find the best local fit
[xfitted,errorfitted] = lsqcurvefit(fitfcn,p0,xdata,ydata,lb,ub)
%Set up the problem for MultiStart.
problem = createOptimProblem('lsqcurvefit','x0',p0,'objective',fitfcn,...
'lb',lb,'ub',ub,'xdata',xdata,'ydata',ydata);
% Find a global solution.
ms = MultiStart('PlotFcns',@gsplotbestf);
[xmulti,errormulti] = run(ms,problem,200)
I am not sure what I'm doing wrong.
Accepted Answer
More Answers (0)
Categories
Find more on Global or Multiple Starting Point Search 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!