Exponential/Power curve fitting from data
Show older comments
Hey
I would like some help on finding some unknown constants in an equation, from some data i have.
The function I have is the following
y = k1 * d1^(k2/2) * d2^(k3/2) * d3^k4
from measurements i have [y d1 d2 d3] and i need to know [k1 k2 k3 k4].
I tried to solve this function in excel using the LOGEST function and it solves for
y = b * m1^x1 * m2^x2...etc
where mn is the unknowns.
What i did there was to set exp(ln) the function to get it the way i needed to be and it solved it just fine.
What i want to do is the same thing except in matlab. I'm kinda lost on what function to use and so on.
Because it requires start values and only one in-value (x) while i have 3 different values.
This is as far as i came before i got stuck
% k = [k1 k2 k3 k4]
% d = [data1 data2 data3]
% y
% y and d known and in a list
modelfun = @(k,d)
k(1)*exp(p(1)*k(2))*exp(p(2)*k(3))*exp(p(3)*k(4))
start = [2 0.2 1.5 -.5]
coef = nlinfit(???,y,modelfun,start)
the thing is i wanna be able to plot y against any of those three.
Thanks
Sorry for the bad english
Answers (4)
Mamed
on 25 Oct 2011
Daniel Shub
on 25 Oct 2011
I think if you log transform everything you can eliminate the fminsearch and treat the problem as optimizing a linear equation. Basically rewrite
y = k1 * d1^(k2/2) * d2^(k3/2) * d3^k4
as
log(y) = log(k1)+(k2/2)*d1+(k3/2)d2+(k4)*d3;
and solve for log(k1), k2, k3, k4 with techniques designed for linear equations.
Mamed
on 25 Oct 2011
2 Comments
Daniel Shub
on 25 Oct 2011
Don't do a fitting procedure (e.g., lsqnonlin). In this form, all you need to do is a linear regression. You can explicitly solve for the optimum parameters.
Mamed
on 2 Nov 2011
Mamed
on 17 Jan 2012
0 votes
1 Comment
Walter Roberson
on 17 Jan 2012
I think you should probably start a new Question for this topic.
Categories
Find more on Get Started with Curve Fitting Toolbox 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!