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