Equation and plot of an image

1 次查看(过去 30 天)
OLuxanna
OLuxanna 2022-11-7
Hello;
I'm trying to get the exact same of this plot in the image. I've managed to get the exact graph and equation of it but once I try to draw the equation of this plot it gives me something different. May someone please help me? Sincerely yours. Here what I ve done till now;
x = [0
0.002003822
0.002625344
0.003246866
0.003838792
0.00448991
0.00448991
0.004904258
0.005401475
0.005732954
0.006324879
0.007153575
0.007804693
0.007982271
0.008219041
0.008633389
0.008633389
0.008810967
0.009047737
0.009639662
0.010290781
0.010705129
0.011202346
0.01212575
0.013191216
0.013783142
0.01443426
0.01443426
0.014848608
0.015539188
0.015677304
0.016091651
0.016229767
0.017058463
0.017887159
0.019406435
0.019489304
0.019820783
0.020318
0.021063826
0.021063826
0.021892522
0.022168754
0.022721218
0.023826146
0.02437861
0.024792958
0.025384883
0.026036001
0.026450349
0.026864697
0.027693393
0.027693393
0.028798321
0.029350785
0.030179481
0.031008176
0.031422524
0.031974988
0.032665568
0.032843146
0.033770496
0.03432296
0.035980351
0.036809047
0.036891917
0.037637743
0.039378004
0.040372439
0.040869657
0.041781222
0.043438614
0.045096006
0.046836267
0.047582093
0.049322354
0.050068181
0.052001804
0.05421166
0.056875325
0.06001253
0.063051082
0.065122821
0.067677967
0.069211054
0.071199924
0.071614272
0.07410036
0.074929055
0.076835056
0.078160969
0.079072535
0.0799841
0.080907504
0.082387318
0.082801666
0.083133144
0.084597173
0.085619232
0.086447927
0.087773841
0.088326305
0.088602537
0.089638406
0.089707464
0.090674276
0.091502972
0.092746016
0.093160364
0.093367538
0.093574712
0.094817755
0.095232103
0.096060799
0.096475147
0.097303843
0.097303843
0.098132539
0.098132539
0.098961235
0.099513698
0.100618626
0.101447322
0.102027409
0.102966598
0.103519062
0.103684801
0.104762105
0.104762105
0.104762105
0.10583941
0.106005149
0.106419497
0.106833845
0.107662541
0.108491237
0.108905584
0.109458048
0.110286744
0.11111544
0.11180602
0.112220368
0.112634716
0.112800455
0.113629151
0.113739643
0.114292107
0.114623586
0.115535151
0.116363847
0.116571021
0.117606891
0.117606891
0.11777263
0.118932804
0.119264282
0.119430022
0.119856208
0.120755935
0.121087413
0.121584631
0.121916109
0.122164718
0.122579066
0.122993414
0.123904979
0.124402197
0.125230892
0.126059588
0.127275009
0.130451676
0.133766459
0.137081243
0.140396026
0.143710809
0.147025593
0.150340376
0.153655159
0.156969943
0.160367596
0.163599509
0.166914293
0.170229076
0.173543859
0.176858643
0.180173426
0.183488209
0.186802993
0.190117776
0.193432559
0.196747343
0.200062126
0.203376909
0.206691693
0.210006476
0.213321259
0.216636042
0.219950826
0.223265609
0.226663262
0.229895176
0.233209959
0.236524742
0.239839526
0.243154309
0.246469092
0.249783876
0.253098659
0.256413442
0.259728226
0.263043009
0.266274923
0.269672576
0.272987359
0.276302142
0.279616926
0.282931709
0.286246492
0.289561276
0.292876059
0.296190842
0.299505626
0.302820409
0.306135192
0.309449976
0.312764759
0.316079542
0.319394325
0.322709109
0.326023892
0.329338675
0.332653459
0.335968242
0.339283025
0.342597809
0.345912592
0.349227375
0.352542159
0.355856942
0.359171725
0.362486509
0.365801292
0.369116075
0.372430859
0.375745642
0.379060425
0.382375209
0.385689992
0.389004775
0.392319559
0.395634342
0.398949125
0.402263909
0.405578692
0.408893475
0.412208259
0.415605911
0.418837825
0.422152608
0.425218783
0.428782175
0.432096958
0.435411742
0.438726525
0.442041308
0.445356092
0.448670875
0.451985658
0.455300442
0.458615225
0.461930008
0.465244792
0.468559575
0.471874358
0.475189142
0.478503925
0.481818708
0.485133492
0.488448275
0.491763058
0.495077842
0.498475495
0.500464364
0.500464364
0.500878712
0.501790278
0.502121756
0.502453234
0.503116191
0.5033648
];
y= [0.1
0.128009528
0.132396064
0.135628249
0.140212674
0.145901978
0.149249598
0.156637449
0.152943523
0.16494878
0.160529263
0.168708668
0.173490982
0.176954037
0.193576701
0.183880147
0.181571444
0.188959294
0.201888032
0.197006774
0.20504326
0.213893289
0.211122845
0.218180881
0.223435929
0.228734953
0.234902489
0.237903803
0.241289901
0.24513774
0.248985579
0.252333198
0.256989083
0.262837798
0.268609556
0.277613499
0.273457833
0.285001349
0.281215076
0.288541361
0.293312681
0.29596769
0.301085315
0.306010549
0.310627956
0.315591668
0.319477985
0.324711045
0.330482804
0.333945858
0.337639784
0.341795449
0.345027634
0.348336775
0.353223531
0.357379196
0.361303992
0.364420741
0.367422056
0.371924027
0.37668985
0.382967324
0.387738644
0.392433008
0.397319763
0.401914082
0.406670011
0.410964199
0.415673954
0.420937797
0.426909643
0.433143142
0.439222727
0.445410052
0.449958197
0.454275472
0.458500399
0.462155846
0.46731195
0.472006313
0.475065345
0.47662372
0.475700238
0.474545887
0.47163692
0.472468054
0.46777369
0.463079327
0.458615834
0.454829561
0.450119806
0.443147522
0.446241185
0.43928869
0.433912709
0.438299245
0.429618521
0.424139199
0.419367879
0.414473428
0.410133066
0.406746968
0.403206956
0.39882042
0.395665192
0.390586045
0.385429941
0.381659059
0.378157526
0.373655554
0.366729445
0.368884234
0.36349726
0.359803335
0.355878539
0.351722873
0.348028948
0.344104153
0.340525663
0.336369997
0.331252371
0.325942354
0.32078625
0.315660929
0.309396647
0.305010111
0.300885228
0.296775736
0.293081811
0.289503321
0.285647786
0.281307424
0.277959805
0.272903744
0.268009293
0.263453452
0.259490178
0.254141683
0.248292968
0.242598166
0.237672933
0.233170961
0.228207249
0.223589843
0.218510696
0.21435503
0.206043698
0.209645275
0.201272378
0.195769969
0.191498868
0.187727986
0.18403406
0.180186222
0.175107075
0.170489668
0.166518698
0.160265411
0.155713967
0.146386806
0.150727168
0.138444867
0.142323488
0.134473897
0.131010842
0.125977869
0.120714026
0.115727227
0.111663909
0.109847729
0.109539902
0.109078161
0.109886208
0.109886208
0.109539902
0.109655337
0.110001643
0.109424467
0.109309032
0.10963225
0.110117078
0.109193597
0.109078161
0.109462945
0.110347948
0.109193597
0.109078161
0.109886208
0.110232513
0.109309032
0.109193597
0.109886208
0.109886208
0.109078161
0.109309032
0.109886208
0.109424467
0.109078161
0.109770772
0.109816947
0.109193597
0.109193597
0.110117078
0.109886208
0.109078161
0.109193597
0.110347948
0.109886208
0.109078161
0.109770772
0.110463383
0.109539902
0.109078161
0.109539902
0.110347948
0.109655337
0.109193597
0.109886208
0.109886208
0.109078161
0.109539902
0.109886208
0.109539902
0.109078161
0.109424467
0.110463383
0.109886208
0.109078161
0.109424467
0.110347948
0.109770772
0.109078161
0.109886208
0.109886208
0.109424467
0.109539902
0.110001643
0.109770772
0.109193597
0.109193597
0.110463383
0.109770772
0.109078161
0.109424467
0.110347948
0.109886208
0.109193597
0.109424467
0.110001643
0.109424467
0.109424467
0.109886208
0.109886208
0.109078161
0.109193597
0.110117078
0.109816947
0.109078161
0.109193597
0.110001643
0.110001643
0.109078161
0.109539902
0.109886208
0.109309032
0.109193597
0.109886208
0.109770772
0.109078161
0.109309032
0.110347948
0.109886208
0.109078161
0.109309032
0.110001643
0.109655337
0.109078161
0.109770772
0.109886208
0.109078161
0.109309032
0.11064808
0.114772963
0.111386865
0.119698196
0.125516129
0.128933009
0.132811631
0.138537215
0.144170451
];
a=polyfit(x,y,11);
b=polyval(a,x);
x1 = linspace(0, 0.4, 290);
y1= polyval(a,x1);
val= - (3475270952860169*x.^9)/2147483648 + (8404527124189405*x.^8)/2147483648 - (265994861691087*x.^7)/67108864 + (4666535833849043*x.^6)/2147483648 - (2980935725561569*x.^5)/4294967296 + (4416493083311329*x.^4)/34359738368 - (3486304182240845*x.^3)/274877906944 + (8856368393556895*x.^2)/17592186044416 + (8788106233231547*x)/9007199254740992 + 0.1;
plot(x1,val,'b','LineWidth',2)

回答(2 个)

VBBV
VBBV 2022-11-7
val= - (3475270952860169*x1.^9)/2147483648 + (8404527124189405*x1.^8)/2147483648 - (265994861691087*x1.^7)/67108864 + (4666535833849043*x1.^6)/2147483648 - (2980935725561569*x1.^5)/4294967296 + (4416493083311329*x1.^4)/34359738368 - (3486304182240845*x1.^3)/274877906944 + (8856368393556895*x1.^2)/17592186044416 + (8788106233231547*x1)/9007199254740992 + 0.1;
Replace x with x1 in above equation

John D'Errico
John D'Errico 2022-11-7
编辑:John D'Errico 2022-11-7
NO polynomial function will EVER have that shape, thus s nice smooth parabolic looking shape, and then almost perfectly constant for a long way? And then a little sharp upward bend at the end? NOT GONNA HAPPEN. EVER. There is no polynomial you can use for that shape. Seriously, what would you expect?
Using polytfit will do wxactly what you should expect: give you complete and unadulterated crap. Of course polyfit does not care, since it is just doing what you asked.
I've attached your data in a mat file to make it easier to load.
load xy.mat
plot(x,y,'.')
grid on
Using a polynomial to fit that entire set of data is an almost criminal act. It looks like maybe your curve almost srts up again, in a periodic way at the end. But even a Fourier series would do strange stuff near the transitions due to Gibbs phenomena.
The curve flattens out at roughly x = 0.127. So if we fit polynomial to the first part, it will be good.
ind = x<=0.127;
p4 = fit(x(ind),y(ind),'poly4');
plot(p4,x(ind),y(ind),'b.')
That fits nearly perfectly. But a high order polynomial fit to the entire curve? That gives you what you should expect.
p11 = fit(x,y,'poly4');
plot(p11,x,y,'b.')
Just about what I would predict. In fact, I might have predicted sometihing even worse, but that is reasonable in context.
So that you got a strange looking polynomial is completely expected. Computers do exactly what you tell them to do. Tell them to do something meaningless, and you should expect something meaningless as a result.

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by