How to call specific number from polyfit

1 次查看(过去 30 天)
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);

采纳的回答

Star Strider
Star Strider 2021-3-11
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')
.

更多回答(1 个)

David Hill
David Hill 2021-3-11
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);

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by