Borrar filtros
Borrar filtros

PPVAL , a short question

1 visualización (últimos 30 días)
Stephan Moeller
Stephan Moeller el 19 de Sept. de 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);

Respuestas (3)

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

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by