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!