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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by