How to call specific number from polyfit

1 visualización (últimos 30 días)
Anastasia Zistatsis
Anastasia Zistatsis el 11 de Mzo. de 2021
Respondida: David Hill el 11 de Mzo. de 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);

Respuesta aceptada

Star Strider
Star Strider el 11 de Mzo. de 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')
.

Más respuestas (1)

David Hill
David Hill el 11 de Mzo. de 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);

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by