Finding exponential curve and r-squared using polyfit

14 vues (au cours des 30 derniers jours)
Jason Rodrigues
Jason Rodrigues le 1 Nov 2018
Modifié(e) : madhan ravi le 1 Nov 2018
I have been trying to figure out how to find the exponential regression and r-squared given a set of x and y values as t and P. The equation I am given is P = a*e^(-b/t) This is my code
temp = [10:10:200];
pres = [1.227, 2.337, 4.241, 7.375, 12.340, 19.920,31.160,47.360, 70.110,101.330,143.270,198.540,270.130,361.380,476.000,618.060,792.020,1002.700,1255.100,1554.900]
tnew = 1.0 ./ (273.15+temp)
logp = log(pres)
AB = polyfit(tnew, logp, 1)
a = exp(AB(1))
b = -AB(2)
curve = a * exp(b./tnew)
r2 = 1 - sum(((a-b)./tnew-logp).^2)/ sum(( logp- mean(logp)).^2)
Can anyone help me out?

Réponses (1)

madhan ravi
madhan ravi le 1 Nov 2018
Modifié(e) : madhan ravi le 1 Nov 2018

Catégories

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

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by