Fitting a data with the best fit

2 vues (au cours des 30 derniers jours)
TTA
TTA le 20 Oct 2022
Modifié(e) : Alex Sha le 22 Oct 2022
Hi guys,
Please, I need a best fitting method for the data below. It is also attached in a text file.
I have tried tried few fitting methods but they are not giving good result.
M = [-40 242.118600000000
-39 242.717400000000
-38 239.597400000000
-37 236.149700000000
-36 241.291400000000
-35 243.789200000000
-34 244.742700000000
-33 237.290600000000
-32 239.856600000000
-31 236.112800000000
-30 233.345900000000
-29 235.154400000000
-28 233.210300000000
-27 235.488400000000
-26 230.774800000000
-25 237.738900000000
-24 237.066600000000
-23 242.997300000000
-22 241.418500000000
-21 243.022000000000
-20 251.080400000000
-19 255.720000000000
-18 257.327500000000
-17 255.298700000000
-16 257.262300000000
-15 259.756300000000
-14 260.172100000000
-13 261.738600000000
-12 262.423100000000
-11 269.295300000000
-10 266.707900000000
-9 263.961600000000
-8 263.291300000000
-7 267.552400000000
-6 266.540300000000
-5 272.394900000000
-4 266.560100000000
-3 265.945800000000
-2 269.381300000000
-1 269.702600000000
0 276.367300000000
1 277.915600000000
2 274.844200000000
3 274.439700000000
4 274.654000000000
5 277.024300000000
6 277.782500000000
7 278.889500000000
8 280.760300000000
9 281.655000000000
10 279.313700000000
11 278.863900000000
12 277.457200000000
13 275.902800000000
14 274.092300000000
15 273.431400000000
16 263.025100000000
17 255.005200000000
18 254.097200000000
19 255.055100000000
20 243.951200000000
21 236.658300000000
22 244.101800000000
23 240.492600000000
24 245.866900000000
25 239.299800000000
26 233.284500000000
27 234.925100000000
28 246.933500000000
29 231.857000000000
30 238.856600000000
31 234.920200000000
32 232.561800000000
33 242.456800000000
34 237.296900000000
35 235.602100000000
36 246.238300000000
37 240.722800000000
38 256.414100000000
39 243.881000000000];
plot(M(:,1),M(:,2))
Thanks
  2 commentaires
Matt J
Matt J le 20 Oct 2022
What curve model would you be trying to fit to?
dpb
dpb le 20 Oct 2022
"Fit" for what purpose? There's nothing going to model that closely. What detail are you willing to sacrifice for a model of some sort?
One of the smoothing or interpolating splines or somesuch is about all I can imagine doing with the above.

Connectez-vous pour commenter.

Réponse acceptée

David Hill
David Hill le 20 Oct 2022
M = [-40 242.118600000000
-39 242.717400000000
-38 239.597400000000
-37 236.149700000000
-36 241.291400000000
-35 243.789200000000
-34 244.742700000000
-33 237.290600000000
-32 239.856600000000
-31 236.112800000000
-30 233.345900000000
-29 235.154400000000
-28 233.210300000000
-27 235.488400000000
-26 230.774800000000
-25 237.738900000000
-24 237.066600000000
-23 242.997300000000
-22 241.418500000000
-21 243.022000000000
-20 251.080400000000
-19 255.720000000000
-18 257.327500000000
-17 255.298700000000
-16 257.262300000000
-15 259.756300000000
-14 260.172100000000
-13 261.738600000000
-12 262.423100000000
-11 269.295300000000
-10 266.707900000000
-9 263.961600000000
-8 263.291300000000
-7 267.552400000000
-6 266.540300000000
-5 272.394900000000
-4 266.560100000000
-3 265.945800000000
-2 269.381300000000
-1 269.702600000000
0 276.367300000000
1 277.915600000000
2 274.844200000000
3 274.439700000000
4 274.654000000000
5 277.024300000000
6 277.782500000000
7 278.889500000000
8 280.760300000000
9 281.655000000000
10 279.313700000000
11 278.863900000000
12 277.457200000000
13 275.902800000000
14 274.092300000000
15 273.431400000000
16 263.025100000000
17 255.005200000000
18 254.097200000000
19 255.055100000000
20 243.951200000000
21 236.658300000000
22 244.101800000000
23 240.492600000000
24 245.866900000000
25 239.299800000000
26 233.284500000000
27 234.925100000000
28 246.933500000000
29 231.857000000000
30 238.856600000000
31 234.920200000000
32 232.561800000000
33 242.456800000000
34 237.296900000000
35 235.602100000000
36 246.238300000000
37 240.722800000000
38 256.414100000000
39 243.881000000000];
p=polyfit(M(:,1),M(:,2),5);%change to desired degree
plot(M(:,1),polyval(p,M(:,1)))
hold on;
plot(M(:,1),M(:,2))
  1 commentaire
TTA
TTA le 20 Oct 2022
Thanks David

Connectez-vous pour commenter.

Plus de réponses (2)

Torsten
Torsten le 20 Oct 2022
Modifié(e) : Torsten le 20 Oct 2022
Try "fit" with fitType
gaussEqn = 'a*exp(-((x-b)/c)^2)+d'

John D'Errico
John D'Errico le 20 Oct 2022
As others have said, there is no magical way to know what is the "best" fitting model for such a problem. If you lack any model based on physical principles, then there is little magic you can do.
These are typically problems where a spine model of some sort may be best, since a spline makes very little in the way of assumptions, except that the curve be relatively smooth.
For example, using my SLM toolbox, there is relatively no information to provide, beyond a rough degree of fit in terms of how many knots to use, so I would do something like this:
slm = slmengine(x,y,'knots',7,'plot','on')
In the end, the result seems reasonable, but it depends on how much you want to chase what may well be noise.
  1 commentaire
Alex Sha
Alex Sha le 22 Oct 2022
Modifié(e) : Alex Sha le 22 Oct 2022
If want to have an explicit function expression,refer to one below:
y = p4*(1/(1+exp(p1*x+p8)))+p5*(1/(1+exp(p2*x+p9)))+p6*(1/(1+exp(p3*x+p10)))+p11+p7*x;
Sum Squared Error (SSE): 931.576981042263
Root of Mean Square Error (RMSE): 3.41243494634378
Correlation Coef. (R): 0.976919416755453
R-Square: 0.954371546833815
Parameter Best Estimate Std. Deviation Confidence Bounds[95%]
--------- ------------- -------------- --------------------------------
p1 2.17071637227502 2.00375241483378 [-1.82666032070769, 6.16809306525773]
p2 -0.866846695995501 0.502259597641453 [-1.86882717750392, 0.135133785512921]
p3 0.357015983521599 0.0432728726246512 [0.270688964680532, 0.443343002362667]
p4 -13.1100496826724 2.55813476865172 [-18.2133889106205, -8.00671045472424]
p5 -16.4803026879968 2.88984006155108 [-22.2453758691813, -10.7152295068122]
p6 64.8893226472405 4.37934503986771 [56.1527683387838, 73.6258769556972]
p7 0.948998342347286 0.0993732061413023 [0.750754220371189, 1.14724246432338]
p8 44.370594281755 40.924919037562 [-37.2723853158642, 126.013573879374]
p9 -27.8000726945408 16.0846620989817 [-59.8880956024535, 4.2879502133719]
p10 -6.25791814028238 0.774805804682342 [-7.80361342793189, -4.71222285263287]
p11 225.224588689396 3.53354087170702 [218.17536752829, 232.273809850502]

Connectez-vous pour commenter.

Catégories

En savoir plus sur Linear and Nonlinear Regression 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!

Translated by