I am having trouble finding the curve fit of an equation in matlab

27 views (last 30 days)
In a homework problem I am doing it asks me to find the curve fit of an equation by linearizing the relationship and then using polyfit to find the constants A and B but the issue I am having is that the equation in question is Axe^(Bx) and the data points are x = [0.1 0.2 0.4 0.6 0.9 1.3 1.5 1.7 1.8] and y = [0.75 1.25 1.45 1.25 0.85 0.55 0.35 0.28 0.18]. The main issue I am having is finding the constants of the equation. I have managed to linearize the equation down to ln(y) = ln(A) + ln(x) + Bx but I don't know how to put that into polyfit to get the constants. Any help would be appreciated.

Accepted Answer

Rik
Rik on 2 Jun 2020
You're almost there:
ln(y) = ln(A) + ln(x) + B*x
ln(y) - ln(x) = ln(A) + B*x
%so:
y2 = ln(y) - ln(x);
p = polyfit(x,y2,1);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!