How to get the coefficient uncertainty by polyfit?
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Severin Handelshauser
le 23 Mar 2020
Commenté : darova
le 23 Mar 2020
I used the Matlab polynomial fit. I would then like to have the fit parameters with their uncertainty e.g. have a1 = 1,345 +/- 0.023 output.
fp are the fit parameters. There is a triangular matrix in error, which is output as an R variable. I know that this is somehow related to the Vandermonde matrix. But how do I get the uncertainties of the individual fit parameters?
I used these values for testing in a .txt-Datei
DickeAFM(nm) KontrastRed
1.0000 0.5510
6.2105 2.1668
11.4211 3.6191
16.6316 3.8623
21.8421 2.5386
27.0526 1.3215
32.2632 0.0862
37.4737 -0.1983
42.6842 0.7642
47.8947 2.7360
53.1053 4.9756
58.3158 6.5082
63.5263 7.7232
68.7368 7.4745
73.9474 6.0571
79.1579 4.5283
84.3684 3.6237
89.5789 3.7593
94.7895 5.2323
100.0000 7.2310
delimiter = '\t';
startRow = 2;
formatSpec = '%f%f%[^\n\r]';
[file,path] = uigetfile;
filename = fullfile(path, file);
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
fclose(fileID);
d=cell2mat(dataArray(1));
I=cell2mat(dataArray(2));
n=9;
[fP,Error]=polyfit(d,I,n);
0 commentaires
Réponse acceptée
darova
le 23 Mar 2020
Try fit
x1 = linspace(x(1),x(end),100);
F=fit(x,y,'poly9')
plot(x,y)
hold on
plot(x1,F(x1),'r')
hold off
F =
Linear model Poly9:
F(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +
p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10
Coefficients (with 95% confidence bounds):
p1 = 9.68e-15 (-3.893e-15, 2.325e-14)
p2 = -4.35e-12 (-1.053e-11, 1.827e-12)
p3 = 7.335e-10 (-4.463e-10, 1.913e-09)
p4 = -5.364e-08 (-1.764e-07, 6.914e-08)
p5 = 9.72e-07 (-6.588e-06, 8.532e-06)
p6 = 8.03e-05 (-0.0001994, 0.00036)
p7 = -0.004159 (-0.01019, 0.00187)
p8 = 0.05116 (-0.01818, 0.1205)
p9 = 0.1133 (-0.236, 0.4626)
p10 = 0.3849 (-0.09655, 0.8663)
3 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Historical Contests dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!