how can I fit the following points to equation "f(x) = a + b*exp(-c*x)"

1 回表示 (過去 30 日間)
Sanskar Agrawal
Sanskar Agrawal 2019 年 10 月 14 日
回答済み: Star Strider 2019 年 10 月 14 日
x = 30, 60, 90, 120, 150, 180, 240, 270, 300, 330, 360, 390, 420
y = 333.15, 332.15, 330.65, 330.15, 329.15, 328.15, 327.65, 326.65, 326.15, 325.15, 324.65, 324.15, 323.15, 322.65, 322.15, 321.65

採用された回答

Star Strider
Star Strider 2019 年 10 月 14 日
Try this:
x = [30, 60, 90, 120, 150, 180, 240, 270, 300, 330, 360, 390, 420];
y = [333.15, 332.15, 330.65, 330.15, 329.15, 328.15, 327.65, 326.65, 326.15, 325.15, 324.65, 324.15, 323.15, 322.65, 322.15, 321.6];
yt = y(1:numel(x)); % Truncate ‘y’ To Match Length Of ‘x’
f = @(b,x) b(1) + b(2).*exp(b(3).*x); % Objective Function
[B,fval] = fminsearch(@(b)norm(yt - f(b,x)), [100; 10; -1]); % Estimate Parameters
xe = linspace(min(x), max(x)); % Higher-Resolution ‘x’
figure
plot(x, yt, 'p')
hold on
plot(xe, f(B,xe), '-r')
hold off
grid
legend('Data','Regression Equation')
xl = xlim;
yl = ylim;
text(0.2*diff(xl)+min(xl), 0.1*diff(yl)+min(yl), sprintf('$y(x) = %.1f + %.1f e^{%.6f}$', B), 'Interpreter','latex')
Provide additional elements for ‘x’ to fit all the elements of ‘y’.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by