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

2 Ansichten (letzte 30 Tage)
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)].

Antworten (1)

Star Strider
Star Strider am 16 Mär. 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.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by