Azzera filtri
Azzera filtri

gradient of the fit with uncertainty and R

4 visualizzazioni (ultimi 30 giorni)
I have a linear fit graph. I used polyfit to compute linear fit.
I would like to calculate the gradient of the fit with error and R. Is there any function in Matlab to calculate R?
I found one solution in Mathworks which is given below
[b, bint] = polyfit(x,y,1); b_err = sqrt(diag((bint.R)\inv(bint.R'))./bint.normr.^2./bint.df);
But I didn't understand the formula.
Any help from anyone?

Risposta accettata

Star Strider
Star Strider il 14 Set 2018
See the section in the polyfit (link) documentation on Output Arguments, specifically R (link). It is the ‘Triangular factor from a QR decomposition of the Vandermonde matrix of x’.
Since ‘R’ is a field of ‘bint’ (in the example you posted), there is nothing further you need to do, since ‘R’ is calculated for you. (If I remember correctly, the ‘R’ field is the covariance matrix. It has been a while since I explored polyfit.)

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by