Global fit of two set data points with common parameters (lsqcurvefit) but different models?
2 views (last 30 days)
Show older comments
Hi. I have two set of data points (with common xdata set e.g. (x,y1,y2)). That means two yexp are there for each (x1,x2,x3..). Now for lsqcurvefit, I have designed my set of two functions (which are partially different but use same set of parameters) and the output for two functions are collected in a Y(calc) vector. e.g
Y(calc)= [(y1calc(x1),y1calc(x2),y1calc(x3)....y2calc(x1),y2calc(x2)y2calc(x3)...], where y1calc's are calculated values from model1 and y2calc's are from model2. Also the Ydata (exp) that I am giving is in same order so that lsqcurvefit can work correctly. Xdata for which Y's are calculated at each points are repeated according to Y(calc) e.g. Xdata=(x1,x2,x3....x1,x2,x3) Is this the right approach to the situation? I hope I was able to explain it correctly. Thanks
0 Comments
Accepted Answer
Matt J
on 15 Jan 2017
Edited: Matt J
on 15 Jan 2017
Xdata for which Y's are calculated at each points are repeated according to Y(calc) e.g. Xdata=(x1,x2,x3....x1,x2,x3) Is this the right approach to the situation?
No, duplicating the Xdata is unnecessary and likely to cause errors. You should write your model function Ycalc=F(x,Xdata) so that it takes as input an Xdata matrix containing a single copy of all the x-values
Xdata=[x1,x2,x3,...xN]
and returns as output a matrix of all the y-values
Ycalc=[(y1calc(x1),y1calc(x2),y1calc(x3)
y2calc(x1),y2calc(x2)y2calc(x3)...]
The output Ycalc should be a matrix of the same size and shape as your Ydata input and the elements Ycalc(i) should be ordered such that you want Ycalc(i) to fit Ydata(i) as closely as possible. That is all that lsqcurvefit cares about.
3 Comments
Matt J
on 15 Jan 2017
Edited: Matt J
on 15 Jan 2017
You are saying that the ycalc is a row matrix (1x2n) order where I have 2n number of Y calculated , in the same order as my experimental data. Right?
I'm saying, if your experimental ydata is a 1x2n matrix then ycalc must also be 1x2n and in corresponding order. But you are free to organize ycalc and ydata in any shape that is convenient to you. They could both be 2xn, for example, again just as long as they are in corresponding order.
It doesn't matter that the size of xdata is half of the Ydata.
Right. The size/dimensionality of Xdata is completely unrelated to the size/dimensionality of Ydata. You could have a 1x1 matrix for Xdata and a 1000x800x500 Ydata if that's what your model F(params,xdata) dictated.
However, the dimensionality of Ycalc and Ydata must be the same.
More Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression 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!