simultaneous curve fitting using "fmincon"

Hi, I'm new with Optimazation function. I m trying to simultaneous fit more than 2 data set but using the same function with different parameters (11) among which 2 vary linearly. I also have to set a boundaries for this parameters according to physically acceptable value.
here is my code for 2 data set:
load E30_data.txt;
load E60_data.txt;
y30 = E30_data(:,2);
y60 = E60_data(:,2);
lambda = E30_data(:,1);
nonlcon = [];
lb = [0.001 1.55 0.002 24000 1000 2.1460 1000 1000 1.3545 1000 02562];
ub = [0.009 2.45 11.8 48000 4000 3.600 8756 5E11 1.90545 8965 6E11];
x0 = [0.004 1.99 2.8 39750 2850 2.8773 6880 2944683560 1.5251 7812 167964024];
options = optimset('Display','iter','MaxFunevals',4000,'TolFun',1e-10 ,'Algorithm','trust-region-reflective','GradObj','on');
fitfunc = @(c)fitfunction(c,y30,y60);
parameter =fmincon(fitfunc,x0,[],[],[],[],lb,ub,nonlcon,options);
where the function fmincon is:
function error = fitfunction(c,y30,y60)
y1 = mie_extinction(c(1:11));
y2 = mie_extinction(c(12:22));
error = norm(y30 - y1') + norm(y60 - y2');
and the function mie_extinction help for theoretical calculation for y1 and y2.
By compiling my main code I have the error:
Error using fitfunction
Too many output arguments. Error in @(c)fitfunction(c,y30,y60)
Error in fmincon (line 649)
[initVals.f,initVals.g] =
feval(funfcn{3},X,varargin{:});
Error in demofitextinction_v200114 (line 55)
parameter
=fmincon(fitfunc,x0,[],[],[],[],lb,ub,nonlcon,options);
Caused by: Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
I try my best solving this problem but I could'nt.
It would be a great help if someone can help me overcome this problem.
thanks in advance

 Respuesta aceptada

Amit
Amit el 20 de En. de 2014
Editada: Amit el 20 de En. de 2014
This is because you have GradObj On but your function does not provide gradient vector.
Try something like this:
options = optimset('Display','iter','MaxFunevals',4000,'TolFun',1e-10 ,'Algorithm','interior-point');
fitfunc = @(c)fitfunction(c,y30,y60);
parameter =fmincon(fitfunc,x0,[],[],[],[],lb,ub,nonlcon,options);

5 comentarios

Thanks Amit for your response. I eliminate GradObj and replace the algoritm by 'interior-point' as you sugested and it did'nt solve my problem, but it gave another error message like:
Index exceeds matrix dimensions.
Error in fitfunction (line 19)
y2 = mie_extinction(c(12:22));
Error in @(c)fitfunction(c,y30,y60)
Error in fmincon (line 640)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in demofitextinction_v200114 (line 54)
parameter
=fmincon(fitfunc,x0,[],[],[],[],lb,ub,nonlcon,options);
Caused by: Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
Amit
Amit el 20 de En. de 2014
One thing that I see on first glance is, the c is suppose to be 22x1 size, however x0 (initial guess) is only 11x1 in size.
RoDo
RoDo el 20 de En. de 2014
x0 ist the start parameter. And c schoud be the output values corresponding to parameters, when y1 fits y30 (here with parameters c1 = c(1:11)) and y2 also fits y60 (here with parameters c2 = c(12:22)).
Amit
Amit el 20 de En. de 2014
Thats what I am saying. that c is 22x1 vector and not 11x1. You are trying to optimize c using the initial values provided as x0. The dimensions of x0 and c should be same in order for fmincon to start.
RoDo
RoDo el 20 de En. de 2014
thanks a lot Amit.
By just enlarging the size of x0 to the same size like c, my program works. Now I just have to refine it to get the expected values.
Once again great thank!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 20 de En. de 2014

Comentada:

el 20 de En. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by