splines, polyfit and polyval, wrong coefficients?!?

조회 수: 2 (최근 30일)
David
David 2014년 7월 9일
편집: David 2014년 7월 9일
Good morning all together,
I have a question concerning the spline function and it´s coefficients (MATLAB R2012b). I have created a function out of two clothoids which looks like this.
Now I want to evaluate this function piecewise by fitting a cubic spline. Afterwards I took a look at the coefficients and tried to find the piecewise polynomial function:
y = spline(xges,yges);
xev = linspace (0,1,10);
hold on
for i =1:length(y.coefs)
br = y.breaks(i:i+1);
xxp(i,:) = linspace(br(1),br(2),10);
cf = y.coefs(i,:);
yp(i,:) = polyval(cf,xev);
% ypp (i,:) = ppval(y,xxp(i,:));
plot(xxp(i,:),yp(i,:),'.g') ;
end
But it doesn´t fit the function. The piecewise polynomial functions are wrong. So are also the coefficients of the cubic spline wrong? Or am I doing some mistake by evaluating the piecewise polynomial functions? It´s also a little bit weird that the spline looks perfect, when I´m not using the polyval, but the ppval function. (Blue line is with ppval, green lines with polyval)
I hope you can help me
Thank you in advance,
David

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by