
Exponential fit using Linear Regression
13 views (last 30 days)
Show older comments
Nathaniel Irvin
on 10 Oct 2018
Commented: Nathaniel Irvin
on 11 Oct 2018
I am trying to fit an exponential line in my graph. I can get a linear line, but I can't seem to figure out how to make it an exponential. clear T = (10:10:150); H = [7.741, 5.906, 4.762, 3.838, 3.019, 2.415, 1.544, 1.316, 1.199, 0.676, 0.537, 0.316, 0.201, 0.168, 0.123]; TH = polyfit(T, H, 1); plot(T, H,'*',T, line, '-');
I don't know where to go from here any help is appreciated.
0 Comments
Accepted Answer
John D'Errico
on 10 Oct 2018
Edited: John D'Errico
on 10 Oct 2018
Write down the model you want to use. DO IT! You can't solve this unless you understand & think about what you are doing. That requires you know the model.
First, let me plot the curve, so we can all see it.
plot(T,H)

So I'll assume, when you say an exponential model, that you mean the simple model:
H(T) = a*exp(b*T)
That model is consistent with your data if b is negative, since it approaches zero for large T, and gets large for small T.
Take the log of your model. The natural log, so use log.
log(H) = log(a) + b*T
Now, you have no idea what log(a) is, so you also have no idea what a is. a is just an unknown here. Who cares? Just call log(a) some other number.
log(H) = c + b*T
Can you fit that model? (Hint: Can you use polyfit?) What would this do for you?
bc = polyfit(T,log(H),1);
What are b and c here? Can you now recover the value of a, given that c=log(a)? Remember that is a natural log.
Finally, there is one issue here, in that you do screw around with the error structure of your model, implicitly assuming a lognormal noise structure. At some point in your modeling career, this will be something you might start thinking about. But for now, it is a somewhat minor issue.
3 Comments
John D'Errico
on 11 Oct 2018
Edited: John D'Errico
on 11 Oct 2018
What is y here? (Hint: H)
What is x here? T
TRY IT!!!!
bc = polyfit(T,log(H),1)
bc =
-0.0300522077208321 2.5345806082436
exp(bc(2))
ans =
12.6111407303375
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!