lsqcurvefit for several data sets at once
5 views (last 30 days)
Show older comments
Hello,
I would like to generate a function using lsqcurvefit. I do have a few data sets from several experiments. Every experiment has different parameters and one variable. Now I would like to generate a function with lsqcurvefit. But I want this function to be optimised for all data sets at once. Is there a way to do this? Or should I use another tool for that?
For example my data looks like this:
% Experiment 1
a1 = 0.416;
b1 = 2;
c1 = 2;
x1 = [0 0.33 0.67 1 1.33 2];
y1 = [1 0.89 0.8 0.44 0.62 0.37];
% Experiment 2
a2 = 0.801;
b2 = 0.67;
c2 = 4;
x2 = [0 0.17 0.33 0.5 0.67];
y2 = [1 0.8 0.84 0.83 0.81];
% and so on...
Thanks for your answers!
4 Comments
Adam Danz
on 11 Mar 2019
Edited: Adam Danz
on 11 Mar 2019
So you'd like to combine the data across experiments and fit it is one large data set? You mentioned that data from each experiment has different parameters which would potentially weaken the goodness of fit and/or variance of the data. Maybe I don't understand still. What would your inputs look like?
Accepted Answer
Adam Danz
on 11 Mar 2019
Edited: Adam Danz
on 12 Mar 2019
Continuing from the comment section under the question, to combine data sets (x1, x2....) and (y1, y2, ...) just combine them in the same order to preserver the 1:1 correspondence between the xdata and ydata inputs. For the x0 initial starting points and the upper/lower bounds, you should systematically choose the best options from your individual data sets.
x = lsqcurvefit(fun,x0,[x1, x2], [y1, y2],lb,ub)
7 Comments
Adam Danz
on 12 Mar 2019
Edited: Adam Danz
on 12 Mar 2019
I enjoying helping and I learn a lot by doing so. It seems that the question you're asking isn't quite clear and I think the questions should be rock solild before you start with the solutions. For example, if you're trying to measure the difference in performance between the different concretes, you could fit a function to each data set and plot out the coefficients to determine the influence of each parameter on each concrete type. If you're just determining if there is a statistically significant difference between the concrete types a simple analysis of variance would be a better measure than curve fitting.
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox 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!