Filter löschen
Filter löschen

PPVAL , a short question

1 Ansicht (letzte 30 Tage)
Stephan Moeller
Stephan Moeller am 19 Sep. 2011
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);

Antworten (3)

Wayne King
Wayne King am 19 Sep. 2011
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 am 19 Sep. 2011
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 am 19 Sep. 2011
Thanks for the answer, - now I understand !

Kategorien

Mehr zu Polynomials finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by