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

조회 수: 10 (최근 30일)
Vahram Voskerchyan
Vahram Voskerchyan 2021년 9월 20일
댓글: Alex Sha 2021년 9월 20일
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
Alex Sha
Alex Sha 2021년 9월 20일
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

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2021년 9월 20일
편집: the cyclist 2021년 9월 20일
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
Vahram Voskerchyan
Vahram Voskerchyan 2021년 9월 20일
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 2021년 9월 20일
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).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 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