PPVAL , a short question

조회 수: 2 (최근 30일)
Stephan Moeller
Stephan Moeller 2011년 9월 19일
If I use 2 piecewise polynoms with both y=x and breaks at 1 2 3 and input is 1 2 3
I would expect y = 1 2 3
But I get y = 0 0 1.
Why ?
example :
x = linspace(1,3,3)
breaks=[1 2 3];
coefs=[1 0; 1 0];
pp = mkpp(breaks,coefs);
y=ppval(pp,x);

답변 (3개)

Wayne King
Wayne King 2011년 9월 19일
Hi Stephan, the polynomials are not y=x.
Your polynomials are
f(x) = x-1 % x-break(1)
g(x) = x-2 % x-break(2)
So that is why you get y = [0 0 1].
From the command line help:
The matrix COEFS must be L-by-K, with the i-th row, COEFS(i,:), representing the local coefficients of the order K polynomial on the interval [BREAKS(i) ... BREAKS(i+1)], i.e., the polynomial COEFS(i,1)*(X-BREAKS(i))^(K-1) + COEFS(i,2)*(X-BREAKS(i))^(K-2) + ... COEFS(i,K-1)*(X-BREAKS(i)) + COEFS(i,K)
Hope that helps,
Wayne

Andrei Bobrov
Andrei Bobrov 2011년 9월 19일
x = linspace(1,3,3)
breaks=[1 2 3];
coefs=[1 1; 1 2];
pp = mkpp(breaks,coefs)
y=ppval(pp,[1 2 3])

Stephan Moeller
Stephan Moeller 2011년 9월 19일
Thanks for the answer, - now I understand !

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by