How to fit two data sets, y1 and y2, to different functions with shared parameters.

2 visualizzazioni (ultimi 30 giorni)
The two data vectors, y1(x) and y2(x), have a common x vector (dimension ~30) and common fit parameters, a=[a1,a2,a3,a4] The two fitting equations are biexponentials:
y1 = a1+[a2*exp(-x/a3)] + [(1-a2)*exp(-x/a4)] and
y2 = a1+[a2*exp(-x/a4)] + [(1-a2)*exp(-x/a3)].

Risposte (1)

Star Strider
Star Strider il 16 Mar 2020
This problems requires lsqcurvefit since the fit is to a matrix and not vector dependent variables:
y1 = rand(10,1); % Create Data
y2 = rand(10,1); % Create Data
x = 0:9; % Create Data
objfcn = @(a,x) [a(1)+a(2).*exp(-x./a(3)) + (1-a(2)).*exp(-x./a(4));
a(1)+a(2).*exp(-x./a(4)) + (1-a(2)).*exp(-x./a(3))];
a0 = rand(4,1); % Use Appropriate Initial Parameter Estimates
B = lsqcurvefit(objfcn, a0, x(:).', [y1(:) y2(:)].'); % Forced Column Vectors & Transpositions Force Data To Conform To Objective Function Size
It does not matter of the data are row or column variables, since the code forces them to fit the ‘objfcn’ dimensions.

Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by