splines, polyfit and polyval, wrong coefficients?!?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!