Ayushi Sharma
Ayushi Sharma

Reputation: 1

Fitting a custom equation in Matlab

I want to fit this equation to find the value of variables, Particularly 'c'

a*exp(-x/T) +c*(T*(exp(-x/T)-1)+x)

I do have the values of `

a = -45793671; T = 64.3096

due to the lack of initial parameters, the SSE and RMSE errors in cftool MATLAB are too high and it's not able to fit the data at all. I also tried other methods (linear fitting) but the problem with high error persists.

Is there any way to fit the data nicely so that I can find the most accurate value for c?

for x: 
 0
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20

`

for y:
-45793671
-87174030
-124726368
-165435857
-211887711
-255565545
-295927582
-332434440
-365137627
-383107046
-408000987
-434975682
-465932505
-492048864
-513857005
-543087921
-573111110
-588176196
-607460012
-628445691

Upvotes: 0

Views: 281

Answers (1)

JJacquelin
JJacquelin

Reputation: 1705

I dont'think that the bad fitting is mainly due to a lack of initial parameters.

First trial :

If we start with the parameters stated in the wording of the question : a = -45793671; T = 64.3096 there is only one parameter c remaining to be fitted. The result is not satisfising :

enter image description here

Second trial :

If we keep constant only the specified value of T and optimize two parameters c and a , the RMSE is improved but the shape of the curve remains not good :

enter image description here

Third trial :

If we forget the specified values of the two parameters T,a and proceed with a non-linear regression wrt the three parameters T, c , a the result is better :

enter image description here

But a negative value for T mignt be not acceptable on physical viewpoint. This suggest that the function y(x)=a * exp(-x/T)+c*(T*(exp(-x/T)-1)+x) might be not a good model. You should check if there is no typo in the function and/or if some terms are not missing in order to better model the physical experiment.

For information only (Probably not useful) :

An even better fit is obtained with a much simpler function : y(x) = A + B * x + C * x^2

enter image description here

Upvotes: 1

Related Questions