Fitting Data to a Non-Linear Curve
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Andrew Rowe
le 8 Déc 2019
Réponse apportée : Alex Sha
le 9 Déc 2019
I have matrix data for x and y and am looking to find an equation that best represents this data. We don't believe it is a polynomial line of best fit so polyfit wouldn't be appropriate. Is there a method for finding the equation for logarithmic or exponential through data?
Here's the data for reference:
x=[0 1 2 3 4 5 6 7 8 9 10]
y=[.0242 0.1940 0.2792 0.2358 0.1386 0.0598 0.0238 0.0090 0.0034 0.0013 0.002]
1 commentaire
Image Analyst
le 8 Déc 2019
Looks like it could either be log-normal, or the sum of two normals. Is there some knowledge you have about the physics of the situation that might lead you to prefer one or the other, or even some other equation? What physical process gave rise to these measurements?
x=[0 1 2 3 4 5 6 7 8 9 10]
y=[.0242 0.1940 0.2792 0.2358 0.1386 0.0598 0.0238 0.0090 0.0034 0.0013 0.002]
plot(x, y, 'bs-');
grid on;
I can fit the data to either equation with fitnlm() though with only 10 data points, it will be difficult to definitively state that one is better than the other because the sum of the residuals is less. You'd need many more data points to be more certain which is better.
Réponse acceptée
Star Strider
le 8 Déc 2019
One possibility:
x=[0 1 2 3 4 5 6 7 8 9 10];
y=[.0242 0.1940 0.2792 0.2358 0.1386 0.0598 0.0238 0.0090 0.0034 0.0013 0.002];
objfcn = @(b,x) b(1).*x.*exp(b(2).*x);
B0 = [1; -1];
[B,rsdnrm] = fminsearch(@(b) norm(y - objfcn(b,x)), B0);
xv = linspace(min(x), max(x));
figure
plot(x, y, 'pg')
hold on
plot(xv, objfcn(B,xv), '-r')
hold off
grid
text(4.5, 0.22, sprintf('$y(x) = %.3f \\cdot x \\cdot e^{%+0.3f \\cdot x}$',B), 'Interpreter','latex')
xlabel('x')
ylabel('y(x)')
The most accurate model would be one that models the process that created your data.
This model produces:
0 commentaires
Plus de réponses (1)
Alex Sha
le 9 Déc 2019
If don't care the function type, the follow is one:
y = p1*(p2^x)*(x+p3)^p4;
Root of Mean Square Error (RMSE): 0.0032240913289773
Sum of Squared Residual: 0.000114342413873453
Correlation Coef. (R): 0.999488278914727
R-Square: 0.998976819687923
Adjusted R-Square: 0.998721024609904
Determination Coef. (DC): 0.998955740196223
Chi-Square: 0.00189307571492163
F-Statistic: 2218.55228360604
Parameter Best Estimate
---------- -------------
p1 0.0382808254972641
p2 0.190470576993248
p3 0.932820554835385
p4 4.94812019020198
0 commentaires
Voir également
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!