Obtaining uncertainty in parameters fitting discrete data points with component data, using "\" or "mldivide"
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 9 de Jul. de 2017
0 votos
curvefit() is the only related call that returns r-squared directly. https://www.mathworks.com/help/curvefit/fit.html#outputarg_gof
2 comentarios
Jonas Yeung
el 9 de Jul. de 2017
Editada: Jonas Yeung
el 9 de Jul. de 2017
Walter Roberson
el 9 de Jul. de 2017
%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
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!