필터 지우기
필터 지우기

matlab ppval understanding of centering/displacement in breaks

조회 수: 3 (최근 30일)
Thales
Thales 2019년 11월 24일
댓글: Thales 2019년 11월 25일
The documentation on the ppval function gives the following example:
breaks = [0 4 10 15];
coefs = [0 1 -1 1 1; 0 0 1 -2 53; -1 6 1 4 77];
pp = mkpp(breaks,coefs)
xq = 0:0.01:15;
plot(xq,ppval(pp,xq))
line([4 4],ylim,'LineStyle','--','Color','k')
line([10 10],ylim,'LineStyle','--','Color','k')
I was trying to understando the function, but couldn't figure out why the function behaves as it does.
My understanding of the function was that, from the interval [0,4] the polynomial was p1=[0 1 -1 1 1], from [4 10], p2=[0 0 1 -2 53], and from [10 15], p3=[-1 6 1 4 77]. To my surprise, this is not exactly the case.
If you evaluate the polynomials at, say, x=4, you have:
p1=[0 1 -1 1 1];
p2=[0 0 1 -2 53];
y1 = polyval(p1,4)
y2 = polyval(p2,4)
And you can see y1~=y2. The behaviour of the ppval function calculates the polynomial on the range [4 10] with a displacement. You will get both values to be the same evaluaten the second polynomial at
y2 = polyval(p2,4-4)
So, ppval function evaluates the polynomial on the range [4 10], but the x values are from [0 6]. Why MATLAB does it this way?
And how do I define a polynomial for each range, so that MATLAB uses the polynomial exactly at the point specified (as I first thought the function would behave)?

답변 (1개)

Steven Lord
Steven Lord 2019년 11월 25일
The documentation page for ppval says that the pp input is a struct array created by a function like mkpp. If we look at the mkpp documentation page we can see what the coefficients represent. Note that the coefficients represent a polynomial but it's not a polynomial in x. It's a polynomial in x - breaks(i). Try calling polyval to evaluate the polynomial at (x - breaks(i)).
  댓글 수: 1
Thales
Thales 2019년 11월 25일
I see. But I am curious. Why is it so? Why are the polinomial defined in x-breaks(i)?
And what is a good/fast way to define the polinomials in x?

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

카테고리

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