필터 지우기
필터 지우기

plot and evaluate this cubic polynomial

조회 수: 6 (최근 30일)
enzo milito
enzo milito 2014년 5월 15일
댓글: Benjamin Avants 2014년 5월 16일
I need to evalue this polynomial q(t) = a + b(t - tk1) + c(t - tk1)^2 + d(t - tk1)^3
whit tk1<t<tk2
where a,b,c,d,tk1,tk2 are costant
I think to polyval but it is rigth for : q(t) = a + b*t + c*t^2 + d*t^3 how can evalue and plot my polynomial
thanks

채택된 답변

Benjamin Avants
Benjamin Avants 2014년 5월 15일
I think the easiest thing to do is to first define t as a vector. Choose your resolution and invoke linspace:
numberOfPoints = 1000;
t = linspace(tk1,tk2,numberOfPoints);
then compute q and plot:
q = a + b .* (t - tk1) + c .* (t - tk1).^2 + d .* (t - tk1).^3;
plot(t,q);
  댓글 수: 3
enzo milito
enzo milito 2014년 5월 15일
I tryed your suggestion and run very well, but now I have connect or concatenate two or more different polynomial in different interval time tk1-tk2 tk2-tk3 tk3-tk4 for to obtain one plot from tk1-tk4 and so have you any suggestion ? thanks
Benjamin Avants
Benjamin Avants 2014년 5월 16일
There are a couple of approaches that will accomplish this. I think the best way is to simply compute each segment for the desired polynomial and then do the following:
combinedQ = [q1,q2,q3];
or
combinedQ = [q1;q2;q3]; % depending on whether q is a row or column vector
and then
totalT = [t1,t2,t3]; % Once again, use semicolons if this doesn't work
plot(totalT,combinedQ);

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

추가 답변 (0개)

카테고리

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