How to generate a nonlinear equation from MATLAB?

조회 수: 2 (최근 30일)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA 2022년 9월 12일
답변: Star Strider 2022년 9월 12일
I have the data points of a nonlinear curve.
X=[0 1 1.1 1.15]
Y=[0 0.0042 0.0097 0.016]
But I don not have the curve. How can I generate the curve in MATLAB? Thank you.

채택된 답변

Star Strider
Star Strider 2022년 9월 12일
Try something like this —
X=[0 1 1.1 1.15];
Y=[0 0.0042 0.0097 0.016];
fcn = @(b,x) b(1) .* exp(b(2).*x);
format long
[B,fv] = fminsearch(@(b)norm(Y-fcn(b,X)), rand(2,1))
Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. Current function value: 0.000423
B = 2×1
0.000000462018946 9.076307769820247
fv =
4.232123029691332e-04
xv = linspace(min(X), max(X));
fcnplot = fcn(B,xv);
figure
plot(X, Y, 'p', 'DisplayName','Data')
hold on
plot(xv, fcnplot, '-r', 'DisplayName','Fitted Function')
hold off
grid
xlabel('X')
ylabel('Y')
legend('Location','best')
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by