Azzera filtri
Azzera filtri

PPVAL , a short question

3 visualizzazioni (ultimi 30 giorni)
Stephan Moeller
Stephan Moeller il 19 Set 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);

Risposte (3)

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

Categorie

Scopri di più su Polynomials in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by