How to call specific number from polyfit

2 vues (au cours des 30 derniers jours)
Anastasia Zistatsis
Anastasia Zistatsis le 11 Mar 2021
Hello,
How does one call a specific number from the polyfit below? I'd like to do O27fifth = p(27), but this does not work/isn't right.
T = [0 8 16 24 32 40];
Oxy = [14.621 11.843 9.870 8.418 7.305 6.413];
p = polyfit(T,Oxy, 5);
figure(2)
plot(t,polyval(p,t))
title('fifth order polynomial')
%need Oxy when T = 27
%sfprintf('Oxy(27) = %0.41f\n',O27fifth);

Réponse acceptée

Star Strider
Star Strider le 11 Mar 2021
Try this:
T = [0 8 16 24 32 40];
Oxy = [14.621 11.843 9.870 8.418 7.305 6.413];
p = polyfit(T,Oxy, 5);
pv27 = polyval(p,27);
figure(2)
plot(T,polyval(p,T), 27,pv27,'xr')
title('fifth order polynomial')
text(27,pv27, sprintf('(%d, %.2f)\n\\downarrow',27,pv27),'vert','bottom','horiz','left')
.

Plus de réponses (1)

David Hill
David Hill le 11 Mar 2021
T = [0 8 16 24 32 40];
Oxy = [14.621 11.843 9.870 8.418 7.305 6.413];
p = polyfit(T,Oxy, 5);
figure(2);
plot(T,Oxy,0:.1:40,polyval(p,0:.1:40));
pAt27=polyval(p,27);

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by