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

2 visualizaciones (últimos 30 días)
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)].

Respuestas (1)

Star Strider
Star Strider el 16 de Mzo. de 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.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by