Fitting two Parameters to an equation with data

Hello, I've been stumped trying to solve this problem for a while now and was hoping someone here might be able to help. For background info I'm not completely new to MATLAB, I have a good understanding of the fundamentals and I've developed scripts and functions to run things like Newton-Rhapson method etc...
I have a set of data:
x=[0;69.18248;78.63425;83.30743;86.66291;87.06997]; t=[0;1;2;3;4;5];
And I want to fit an equation to this data. I have the equation shown below:
x= 1 - 0.5584*exp(-a*t) - 0.4416*exp(-b*t)
As you can see, I have the x data points for each t value. I do not, however, know the constant parameters a and b. I wish to find a value for them that will best fit this data. I've looked around for a solution and some say it might be possible using fminsearch but I don't understand how to set up the functions required to do so. Any help is much appreciated.

댓글 수: 4

Matt J
Matt J 2013년 4월 12일
Your equation can't possibly give a good fit to the data you've shown. Your equation gives values less than 1 for all t, but your given x data are very much greater than 1.
R
R 2013년 4월 12일
편집: R 2013년 4월 12일
I was told the value for a was approximately 0.02-0.04 and that b was around 0.0003. I'm just trying to confirm these two values. I know that a should be 100-1000 times larger than b. Also, using your code I get an error:
"Subscripted assignment dimension mismatch.
Error in fminsearch (line 191) fv(:,1) = funfcn(x,varargin{:});"
Yao Li
Yao Li 2013년 4월 12일
I've tried the curve fitting tool. It seems Matt is right. Your equation cannot fit the data well
R
R 2013년 4월 12일
Okay guys, I'm sorry. I was given the wrong data points. Those x values should be /100 as they are percentages...

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

 채택된 답변

Matt J
Matt J 2013년 4월 12일

1 개 추천

y=1-x;
fun=@(ab) abs( .5584*exp(-ab(1)*t)+.4416*exp(-ab(2)*t) - y);
ab=fminsearch(fun,[0,0])
a=ab(1);
b=ab(2);

댓글 수: 2

Matt J
Matt J 2013년 4월 12일
Sorry, should be norm() instead of abs().
R
R 2013년 4월 12일
Alright, thanks a lot for the help! You've solved my problem.

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

추가 답변 (1개)

Yao Li
Yao Li 2013년 4월 12일
편집: Yao Li 2013년 4월 12일

1 개 추천

General model:
f(x) = 1 - 0.5584*exp(-a*x) - 0.4416*exp(-b*x)
Coefficients (with 95% confidence bounds):
a = 16.92 (-2.71e+06, 2.71e+06)
b = 0.3107 (0.2453, 0.3762)
Goodness of fit:
SSE: 0.002167
R-square: 0.9962
Adjusted R-square: 0.9952
RMSE: 0.02328

댓글 수: 2

mht6
mht6 2019년 12월 28일
Could you elaborate on how you achieved/calculated the goodness of fit? It would be nice to apply similar information to data I am fitting
Matt J
Matt J 2019년 12월 28일
By requesting two or more outputs from fit(), see for example,

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

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

질문:

R
R
2013년 4월 11일

댓글:

2019년 12월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by