How to generate a nonlinear equation from MATLAB?

1 visualización (últimos 30 días)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA el 12 de Sept. de 2022
Respondida: Star Strider el 12 de Sept. de 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.

Respuesta aceptada

Star Strider
Star Strider el 12 de Sept. de 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')
.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by