How can I make an exponential fit using two points of my data.

19 visualizzazioni (ultimi 30 giorni)
I have a data that I try to fit which and I get this plot using curve fitting tool box.
x = (length_wg0*10e5)'
y = T_forward_10nm
f = fit (x, y, 'exp1' )
plot (f, x, y)
set(gca, 'YDir','reverse')
but what I want to get is the curve that passes from the first point. Shown in the graph below.
How can I do it?
  1 Commento
Alex Sha
Alex Sha il 20 Set 2021
if take your data as:
x=[0.253629,16.3269,31.0374,58.454,116.959,175.756,231.876,289.34];
y=1.0033,0.969485,0.959453,0.939367,0.00178676,0.00245301,0.00648837,0.00374009];
The fitting function may be taken as:
y=Vmax*x^n/(k^n+x^n)
by adding the constrained condition of passing first point, the results will be:
Root of Mean Square Error (RMSE): 0.0197683134500478
Sum of Squared Residual: 0.00312628973327472
Correlation Coef. (R): 0.999589835353114
R-Square: 0.999179838941266
Parameter Best Estimate
---------- -------------
vmax 1.00329999999224
n -12.6896697136722
k 72.238637792372

Accedi per commentare.

Risposta accettata

the cyclist
the cyclist il 20 Set 2021
Modificato: the cyclist il 20 Set 2021
You can use the 'Weights' Name-Value pair, and heavily weight the first point. Here is a made-up example. Notice how f2 passes through the first point.
x = [0 20 40 60 100 120 140 160]';
y = [1 2 3 4 10 11 12 13]';
f1 = fit (x, y, 'exp1' );
f2 = fit (x, y, 'exp1', 'Weights',[1000 1 1 1 1 1 1 1] );
figure
plot (f1, x, y)
figure
plot (f2, x, y)
  2 Commenti
Vahram Voskerchyan
Vahram Voskerchyan il 20 Set 2021
Thanks a lot for the answer, this worked for my case also. Can you elaborate a little bit what are these [1000 1 1 1 1 1 1 1] if possible?
the cyclist
the cyclist il 20 Set 2021
I suggest you read the documentation for the fit function. Scroll down to "Input Arguments -- Name-Value Pair Arguments".
That is a vector of weights, indicating that the error in the first point should be weighted more heavily (by a factor of 1000) than all the other points (which are weighted equally).

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by