simultaneous curve fitting using "fmincon"
조회 수: 6 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!