simultaneous curve fitting using "fmincon"

1 回表示 (過去 30 日間)
RoDo
RoDo 2014 年 1 月 20 日
コメント済み: RoDo 2014 年 1 月 20 日
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

採用された回答

Amit
Amit 2014 年 1 月 20 日
編集済み: Amit 2014 年 1 月 20 日
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 件のコメント
Amit
Amit 2014 年 1 月 20 日
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 2014 年 1 月 20 日
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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModel Building and Assessment についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by