gradient of the fit with uncertainty and R

10 vues (au cours des 30 derniers jours)
Namira
Namira le 14 Sep 2018
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?

Réponse acceptée

Star Strider
Star Strider le 14 Sep 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.)

Plus de réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by