Extend a line made with polyfit and polyval
Afficher commentaires plus anciens
Hi
I have a problem with extending my polyfit line. I tried to extend it by changing "T" for polyval (which is temperature and x-axis) to contain the whole dataset for temperature to get an extended line ranging the whole plot. I wanted a line that was extended like 4 degrees celsius, but wanted to checking if it worked by including the whole data set first. It did not. All the y-values decreased and the extended line does not look linear any more.
Should this solution work, and if so what have I done wrong?
Is there another solution to extend the line?
Thanks a lot for the help
% Getting index for temperature values
[d,posmin] = min(abs(x11-0));
[d,negmax] = min(x11-10);
x111 = x11(negmax:lastrow11);
[d,negmin1] = min(abs(x111-0));
negmin = negmax+negmin1-1;
% Getting x and y values
T11 = x11(1:posmin); A11 = y11(1:posmin);
T12 = x11(posmin:negmax); A12 = y11(posmin:negmax);
T13 = x11(negmax:negmin); A13 = y11(negmax:negmin);
T14 = x11(negmin:lastrow11); A14 = y11(negmin:lastrow11);
% Fitting values
[p11,s11] = polyfit(T11,A11,1);
f11 = polyval(p11,wholedataset);
[p12,s12] = polyfit(T12,A12,1);
f12 = polyval(p12,T12);
[p13,s13] = polyfit(T13,A13,1);
f13 = polyval(p13,T13);
[p14,s14] = polyfit(T14,A14,1);
f14 = polyval(p14,T14);
1 commentaire
TADA
le 17 Déc 2018
I think it would be best if you could share a sample of your data
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Polynomials dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!