Obtaining uncertainty in parameters fitting discrete data points with component data, using "\" or "mldivide"
이전 댓글 표시
I'm not too familiar with the statistics behind least-square fitting, but please bear with me.
I would like to fit a data set ("Result") with linear combinations of component data sets ("a", "b"). I'm currently using the "\" command, which is equivalent to mldivide:
x =[a;b]'\Result'

A linear combination of the red and yellow curve creates the blue curve that fits the blue curve.
For example, a result would be:
x =
0.9796
0.2119
However, is there any way I can obtain uncertainty/error from doing this? Thanks.
채택된 답변
추가 답변 (1개)
Walter Roberson
2017년 7월 9일
0 개 추천
curvefit() is the only related call that returns r-squared directly. https://www.mathworks.com/help/curvefit/fit.html#outputarg_gof
댓글 수: 2
Jonas Yeung
2017년 7월 9일
편집: Jonas Yeung
2017년 7월 9일
Walter Roberson
2017년 7월 9일
%create some input data.
%replace this section with reading in your a, b, and c
t = linspace(0,1,50);
a = exp(-(t-1/2).^2);
b = tan(t);
x1 = randn(); x2 = randn();
c = a*x1 + b*x2; %x1 and x2 will need to be recovered
%create the fitting type
ft = fittype('a*x1+b*x2', 'coeff', {'x1','x2'}, 'indep', {'a','b'});
%guess an initial solution to keep it quiet
x0 = [.5 .5]
%do the fitting
[x, gof] = fit( [a(:), b(:)], c(:), ft, 'StartPoint', x0 )
%how good was it?
gof.rsquare
카테고리
도움말 센터 및 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!