How to call specific number from polyfit

2 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Star Strider
Star Strider il 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')
.

Più risposte (1)

David Hill
David Hill il 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);

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by