# How to generate a nonlinear equation from MATLAB?

1 vue (au cours des 30 derniers jours)
ANANTA BIJOY BHADRA le 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.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Star Strider le 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')
.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by