Simultanous curve fitting to multiple datasets
9 views (last 30 days)
Show older comments
I want to fit a nonlinear model simultaneously to multiple experimental datasets from different publications.
Besides the dependency of the model equation on the curve fitting parameters(a,b,c), my model also depends on an experimental variable, which defines the loading velocity of the experiment.
The loading velocity is different for each experiment and directly influences the model response. It is predefined and shall not be used for curve fitting.
The following sample data and model function is considered:
x1 = 0:0.1:1;
x2 = 0.05:0.1:0.75;
fun = @(x,a,b,c,velocity) a+b*x+velocity*exp(c.*x);
a_hat=1; b_hat=1; c_hat=1;
y1 = fun(x1, a_hat, b_hat, c_hat, 1.1)+(0.5-rand(1,length(x1)));
y2 = fun(x2, a_hat, b_hat, c_hat, 0.9)+(0.5-rand(1,length(x2)));
What is the best way to get one set of parameters, which fits both experiments?
0 Comments
Accepted Answer
Torsten
on 12 Mar 2022
x1 = 0:0.1:1;
x2 = 0.05:0.1:0.75;
fun = @(x,a,b,c,velocity) a+b*x+velocity.*exp(c.*x);
a_hat=1; b_hat=1; c_hat=1;
y1 = fun(x1, a_hat, b_hat, c_hat, 1.1)+(0.5-rand(1,length(x1)));
y2 = fun(x2, a_hat, b_hat, c_hat, 0.9)+(0.5-rand(1,length(x2)));
x = [x1,x2];
y = [y1,y2];
fun_optim = @(p) fun(x,p(1),p(2),p(3),[1.1*ones(size(x1)),0.9*ones(size(x2))]) - y;
sol = lsqnonlin(fun_optim,[1;1;1])
Note that I changed your original fun from
fun = @(x,a,b,c,velocity) a+b*x+velocity*exp(c.*x);
to
fun = @(x,a,b,c,velocity) a+b*x+velocity.*exp(c.*x);
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!