plotting a polynomial function

조회 수: 716 (최근 30일)
mohammad
mohammad 2011년 12월 14일
편집: Walter Roberson 2023년 10월 23일
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

채택된 답변

mohammad
mohammad 2012년 6월 18일
편집: Walter Roberson 2023년 10월 23일
y_1 = @(x) -0.6729+4.8266*x-0.4855*x.^2+0.0312*x.^3
y_1 = function_handle with value:
@(x)-0.6729+4.8266*x-0.4855*x.^2+0.0312*x.^3
x_1 = 0:0.1:33.5;
plot(x_1,y_1(x_1))
  댓글 수: 3
madhan ravi
madhan ravi 2020년 6월 4일
Guck mal hier Breitenbach:
doc colon
Morne' Breitenbach
Morne' Breitenbach 2020년 6월 5일
Sorry not German or Dutch, my surname is Afrikaanse. so I presume you ment "look here", we write it as "Kyk heir"(said Cake Hirr(like the i in his with a pronounced roll of the r). So the zero means that our number set begins at zero and ends at 33.5, and we get from zero to 33.5 by adding incraments of 0.1? Is this correct?

댓글을 달려면 로그인하십시오.

추가 답변 (5개)

Rubén Lumbiarres
Rubén Lumbiarres 2018년 9월 13일
편집: Walter Roberson 2018년 9월 15일
x=-5:.1:5;
p=[1 -1 -11 9 18] % polynomial function
plot(x,polyval(p,x))
grid on
  댓글 수: 1
Brian Trease
Brian Trease 2020년 11월 24일
Thanks!
I made it one step easier, with no need to specify spacing...
fplot(@(x) polyval(p,x), [-5 5])
grid on

댓글을 달려면 로그인하십시오.


Fangjun Jiang
Fangjun Jiang 2011년 12월 14일
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
mohammad
mohammad 2011년 12월 14일
Thanks Fangjun, how can I plot from T=100 to T=1000?
When I use xlim([100 1000]), It doesn't plot in this interval.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2011년 12월 14일
편집: Walter Roberson 2023년 10월 23일
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
mohammad
mohammad 2011년 12월 14일
Walter, do you mean Because of being so great number (10^2 to 10^20 )it's impossible to see in range of 100 to 1000?
in this interval, value of function is between 0.95 to 0.98 .
Fangjun Jiang
Fangjun Jiang 2011년 12월 14일
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().

댓글을 달려면 로그인하십시오.


Ch
Ch 2022년 9월 4일
x=-5:.1:5;
p=[1 -1 -11 9 18] % polynomial function
p = 1×5
1 -1 -11 9 18
plot(x,polyval(p,x))
grid on

Pink_panther
Pink_panther 2023년 10월 23일
%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)

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by