How to generate a nonlinear equation from MATLAB?

1 Ansicht (letzte 30 Tage)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA am 12 Sep. 2022
Beantwortet: Star Strider am 12 Sep. 2022
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.

Akzeptierte Antwort

Star Strider
Star Strider am 12 Sep. 2022
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')
.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by