How do I plot the first four Chebychev polynomials in MATLAB?

 채택된 답변

Matt Fig
Matt Fig 2011년 3월 3일
Chebychev polynomials of the first or second kind?
Assuming the first kind, you can use the function handle method.
x = -1:.01:1;
C = @(x,n) cos(n*acos(x)); % Generating function.
plot(x,C(x,0),'r',x,C(x,1),'b',x,C(x,2),'k',x,C(x,3),'g')
axis([-1.2 1.2 -1.2 1.2])
legend({'Ch_0';'Ch_1';'Ch_2';'Ch_3'})

댓글 수: 3

I presume that's the first order, see the dot? two dots would mean second order, I'm very sure :)
Oh, I missed that!
nice code, I should have done that way, simple code and easy to plot more polynomials :) +1 vote

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

추가 답변 (1개)

Paulo Silva
Paulo Silva 2011년 3월 3일
clf;hold all;
min=-1;max=1;points=1000;
x=linspace(min,max,points);
t0=1+0*x;
plot(x,t0)
t1=x;
plot(x,t1)
t2=2.*x.^2-1;
plot(x,t2)
t3=4.*x.^3-3*x;
plot(x,t3)
legend('t0=1','t1=x','t2=2*x^2-1','t3=4*x^3-3*x')

카테고리

도움말 센터File Exchange에서 Polynomials에 대해 자세히 알아보기

제품

질문:

2011년 3월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by