MATLAB: Obtaining uncertainty in parameters fitting discrete data points with component data, using “\” or “mldivide”

curve fittingdiscreteerrorMATLABmldivideuncertainty

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.

Best Answer

The statistics and Machine Learning Toolbox regress (link) function can also do this.
For your problem, it would be:
[b,bint] = regress(Result', [a;b]');
with ‘b’ the estimated parameters, and ‘bint’ their confidence intervals.
The documentation says that the F-statistic and p-value (in the stats output if you ask for it) may not be accurate without an intercept term, so ignore them.