Hi, I am new to matlab and am working on a problem trying to fit a straight line through a series of data points, but I need to force the line to cross the origin.
I am using the linfit.m code and would like to modify it to calculate a(2) and the uncertainty in a(2), sa(2) (since a(1) will be 0). The code for linfit.m is attached.
Can anyone provide a suggestion on how to modify the code to force the line through the origin and to estimate the uncertainty in the slope (without using cramer's rule)? I know how to do this by hand and in excel (only 12 data points in the problem), but can't seem to sort it out in the linfit.m code, since it uses cramer's rule which from what I understand will produce a degenerate solution in estimating the uncertainty in the slope a(2) when I force a(1) to be zero.
Any help is greatly appreciated.