how to fit several curves into one curve

I have six dataset ,which are (x1,y1), (x1,y2), (x1,y3), (x1,y4), (x1,y5), (x1,y6), an the expected fitting is as:
AA = w1 * y1 + w2 * y2 + w3 * y3 + w4 * y4 + w5 * y5 ;
w1, w2,w3,w4,w5 are weight factor
delta = (AA / max(AA) - y6)^2 == 0;
the data is attached .
could anyone share his ideal with me to how to solve the problem? thanks a lot!
the y1~y5 dataset plot are following:
the y6 data plot is as following

 Accepted Answer

just now, I find the function "lsqnonneg", although the residual is about big, it sounds working.

6 Comments

you didn't use x1 data anywhere, is it right?
if right, the result will be:
w1 0.513266121252864
w2 0.331937542610903
w3 0.124057751591303
w4 0.0237889810732275
w5 0.00694960347170328
Alex , yes, the x data is not be used.
i am sorry that i have no answer at hand, the fitted result need to be confirmed by further calculation.
however,the result seems better than that produced by lsqnonneg, could you please share the code?
You don't give this data yet.
the fitting is one of the steps which are used to determine a laser intensity distribution. there are two intenstiy profiles from the spec, and Target y( or y6) is one of the two. this is why I have no answer at hand.
if just taking the y axis profile into account, the data needed are all in y1~y6 dataset, if taking x and y axis profile into account, then there need some other data.
all of the dataset is attached.
the expected fitting is as:
AA = w1 * x1 + w2 * x2 + w3 * x3 + w4 * x4 + w5 * x5 + w6 * x6 + w7 * x7 + w8 * x8 ;
BB = w1 * y1 + w2 * y2 + w3 * y3 + w4 * y4 + w5 * y5 + w6 * y6 + w7 * y7 + w8 * y8 ;
w1, w2,w3,w4,w5 ,w6,w7,w8 are weight factor
delta = ( AA / max(AA) - x9 / max(x9) )^2 + (BB / max(BB) - y9 / max(y9) )^2 == 0;

Sign in to comment.

More Answers (1)

just now, make use of the function fminunc, the code is as following:
options = optimoptions(@fminunc,'Diagnostics','on','Display','iter','FunValCheck','on','MaxIterations',1e10,'OptimalityTolerance',1e-12,'PlotFcn','optimplotx','StepTolerance',1e-12);
fun = @(W) sum((sum(x1.*W,2)/max(sum(x1.*W,2)) - xxv/max(xxv)).^2) + sum((sum(y1.*W,2)/max(sum(y1.*W,2)) - yyp/max(yyp)).^2);
W0 =[10000 10000 10000 10000 10000 10000 10000 10000];
[ww ab] = fminunc(fun,W0,options);
get an answer, as following:
ww = [ 25487.4, 17618.4, 10475.0, 4749.7, 19207.7, 8030.61, 1596.92, 330.329]
ab = 7.5882
although the residual is about 8, the x fitting degree of the coincidence is too worse than that for y fitting.
it is appreciated for any suggestion from anyone on how to improve the x fitting degree.

2 Comments

Hi, if your model and data are all correct, the results you get should be the best solution.
Even if you just think about x9 (Ignore y9), the result is just as bad.
Ok, thank you for your kindly confirmation, Alex Sha. tomorrow, i try to do some adjustment to the model, and let see wether any improve will happen

Sign in to comment.

Categories

Asked:

on 27 Apr 2022

Commented:

on 28 Apr 2022

Community Treasure Hunt

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

Start Hunting!