plotting a polynomial function
Afficher commentaires plus anciens
How can I plot a polynomial function in MATLAB? for example:
89.9659+0.1110371T-0.001472155T^2+ 1.1E-5T^3-4.381E-8T^4+1E-10T^5
Réponse acceptée
Plus de réponses (5)
Rubén Lumbiarres
le 13 Sep 2018
Modifié(e) : Walter Roberson
le 15 Sep 2018
x=-5:.1:5;
p=[1 -1 -11 9 18] % polynomial function
plot(x,polyval(p,x))
grid on
1 commentaire
Brian Trease
le 24 Nov 2020
Thanks!
I made it one step easier, with no need to specify spacing...
fplot(@(x) polyval(p,x), [-5 5])
grid on
Fangjun Jiang
le 14 Déc 2011
Of course ezplot(), but you need to fix your formula.
ezplot('89.9659+0.1110371*T-0.001472155*T^2+ 1.1E-5*T^3-4.381E-8*T^4+1E-10*T^5')
1 commentaire
mohammad
le 14 Déc 2011
Walter Roberson
le 14 Déc 2011
Modifié(e) : Walter Roberson
le 23 Oct 2023
You are asking to plot data that has a range of about 10^10 at one end, and about 10^20 at the other end. What are you expecting to see of interest?
T=linspace(100,1000,100);
p=89.9659+0.1110371*T-0.001472155*T.^2+ 1.1E-5*T.^3-4.381E-8*T.^4+1E-10*T.^5;
plot(T,p)
2 commentaires
mohammad
le 14 Déc 2011
Fangjun Jiang
le 14 Déc 2011
No. Because you have small coefficients, the range of p is not from 10^2 to 10^20. The maximum value of p is around 7e4.
The point is, you can specify any range of T as you want, use linspace() or 100:100:1000, then use array power ".^" not the matrix power "^" to evaluate p, and then you can use plot().
x=-5:.1:5;
p=[1 -1 -11 9 18] % polynomial function
plot(x,polyval(p,x))
grid on
%solve1
fplot(@(x)89.9659+0.1110371.*x-0.001472155.*x.^2+1.1E-5.*x.^3-4.381E-8.*x.^4+1E-10.*x.^5)
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!



