フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

piecewise polynomials - ppval . I dont understand it

1 回表示 (過去 30 日間)
Stephan Moeller
Stephan Moeller 2011 年 9 月 14 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
How works ppval ?
If I try to program it with 4 single polynomes in a for-loop with breaks I get a different result compare to ppval.
[breaks,coefs,l,k,d] = unmkpp(pp1);
breaks = [ -1 -0.02 0 0.02 1 ]
coefs =
-0.0122 0.0092 0.1976
-513.7771 -0.0146 0.1950
496.5038 -20.5657 -0.0108
0.0045 -0.7056 -0.2235
p1= coefs(1,1:3); % first polynom coefs
p2= coefs(2,1:3); % second polynom coefs
p3= coefs(3,1:3); % third polynom coefs
p4= coefs(4,1:3); % fourth polynom coefs
x= linspace(-1,1,1000)';
for n=1:1ooo
if x(n)<=breaks(2)
y1(n)=p1(3)+p1(2)*x(n)+p1(1)*x(n).*x(n);
else
y1(n)=0;
end
if x(n)>breaks(2) & x(n)<=breaks(3)
y2(n)=p2(3)+p2(2)*x(n)+p2(1)*x(n).*x(n);
else
y2(n)=0;
end
if x(n)>breaks(3) & x(n)<=breaks(4)
y3(n)=p3(3)+p3(2)*x(n)+p3(1)*x(n).*x(n);
else
y3(n)=0;
end
if x(n)>breaks(4)
y4(n)=p4(3)+p4(2)*x(n)+p4(1)*x(n).*x(n);
else
y4(n)=0;
end
y(n)=y1(n)+y2(n)+y3(n)+y4(n);
end;

回答 (0 件)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by