Fit multiple data with one mathmatical model/function
Show older comments
Hi
I have the following Excel file which contain my data.
The input data is the number of cycles (N) while the output data is the capacity at different temepratures (278.15, 298.15,308.15, 318.15 ).
I want to fit the input and output data with a single function or mathmatical formula, preferably the following equation:
C=a1*(a2-a3*N^0.5) *exp(((-a4/8.314)*(1/T-1/298.15))-((a5/8.314)*(1/T-1/298.15)^2))
Therfore, what I want to do is to get C that correspond to (T and N) everytime. a1-a5 are free fitting parameters.
For T is is clear that I want it to chage only from 278.15 to 318.15.
Can I solve this using lsqcurvefit? or any other better appraoch?
Thanks
Accepted Answer
More Answers (3)
Alex Sha
on 22 Feb 2020
Hello, AHMED, your fit function is overdeterminted which will lead to multi-solutions, the parameter of "a1" is redundant:
C=a1*(a2-a3*N^0.5)*exp(((-a4/8.314)*(1/T-1/298.15))-((a5/8.314)*(1/T-1/298.15)^2));
the effect of above is exact same as the function of below
C=(a2-a3*N^0.5)*exp(((-a4/8.314)*(1/T-1/298.15))-((a5/8.314)*(1/T-1/298.15)^2));
Root of Mean Square Error (RMSE): 2.01307596538931
Sum of Squared Residual: 405.247484242812
Correlation Coef. (R): 0.962621756201578
R-Square: 0.926640645512611
Adjusted R-Square: 0.920394018937605
Determination Coef. (DC): 0.762037250139209
F-Statistic: 19.6453235739073
Parameter Best Estimate
-------------------- -------------
a2 102.235245663151
a3 1.13255810875212
a4 844.097603208569
a5 13460420.8019471
AHMED FAKHRI
on 22 Feb 2020
0 votes
AHMED FAKHRI
on 24 Feb 2020
0 votes
3 Comments
the cyclist
on 24 Feb 2020
If you mean that the tool can find a function, from the entire universe of functions, then no. You have to specify the functional form of the model(s), and then fit for parameters.
Here is a simple example showing why a tool cannot simply find "the best model". Suppose your data were
x = [1 2 3];
y = [2 3 5];
Now, realize that there are an infinite number of functions that will fit those data exactly. An automated tool that finds the "best" function will simply choose one of those. But that does not mean that the model will fit a new sample of data (which is presumably what you care about). This is the problem known as overfitting.
If you don't care about finding a functional form, then there are machine learning methods that will find a fit, and there are techniques to limit overfitting. That's beyond the scope of a simple MATLAB answer. :-)
I can recommend the book and online course Learning from Data to get a better understanding of these ideas.
AHMED FAKHRI
on 24 Feb 2020
the cyclist
on 24 Feb 2020
Usually one chooses the fitting function based on understanding of the underlying process. So, for example, is there some other factor besides number of cycles and temperature, that you are not accounting for? Is there something else that happens at lower temperature, that you can capture with another term?
Of course, it is possible that you just have noise that you cannot really account for. Then your RMSE is simply the best you can do.
Categories
Find more on Correlation Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!