PPVAL , a short question
2 ビュー (過去 30 日間)
古いコメントを表示
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);
0 件のコメント
回答 (3 件)
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
0 件のコメント
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])
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!