Least squares Exponential fit using polyfit
Show older comments
Let's say I'm given x=[11,60,150,200] and y=[800,500,400,90] These are just random numbers (but imagine the solution is in the form of y=a*exp(b*t)
Now, I want to find what 'a' and 'b' are. This is what I'm thinking to do, but I'm not sure if it's correct:
So, if I take ln of both sides of the above equation, I'll get ln(y)= ln(a) +bx. This is in the form of y=mx+b (linear equation).
x= [10, 55, 120, 180]
y= [750, 550, 300, 100]
yPrime= log(y)%take natural logarithm of y data values
pPrime=polyfit(t,yPrime,1)%
aPrime=pPrime(1)
bPrime=pPrime(2)
so now I found the constants for my above LINEAR equation. To find 'a' and 'b' from 'y=a*exp(b*t)', should I now raise the linear constants I found to e? (e^aPrime = a, e^bPrime= b) ?
Is this how I find 'a' and 'b'?
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!