Finding exponential curve and r-squared using polyfit

14 Ansichten (letzte 30 Tage)
Jason Rodrigues
Jason Rodrigues am 1 Nov. 2018
Bearbeitet: madhan ravi am 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?

Antworten (1)

madhan ravi
madhan ravi am 1 Nov. 2018
Bearbeitet: madhan ravi am 1 Nov. 2018

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by