I am having trouble finding the curve fit of an equation in matlab
26 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Rik
2020-6-2
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!