How to fit two data sets, y1 and y2, to different functions with shared parameters.
2 ビュー (過去 30 日間)
古いコメントを表示
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)].
0 件のコメント
回答 (1 件)
Star Strider
2020 年 3 月 16 日
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!