Smoothing spline (spaps)

Hi, I've got a question concerning the behaviour of the 'spaps' function (smoothing spline in curve fitting toolbox). It works as expected if the input vector contains large numbers, but does not seem to work for small numbers. An example:
This behaves as I would expect it:
x = 1:20;
y = 10 + 2*randn(20,1);
tol = ones(20,1);
sp = spaps(x,y,tol); % smoothing spline
subplot(2,1,1)
errorbar(x,y,tol,'LineStyle','none');
hold on
xi = 1:0.1:20;
plot(xi,fnval(sp,xi),'r');
title('spaps(x,y,tol)')
hold off
Now the same as above, but the y and tol values multiplied by 0.01. I would expect the same curve as above (also multiplied by 0.01), but instead the smoothing parameter is 0 resulting in a straight line fit.
scale = 0.01;
y = y*scale;
tol = tol*scale;
sp = spaps(x,y,tol);
subplot(2,1,2)
errorbar(x,y,tol,'LineStyle','none');
hold on
xi = 1:0.1:20;
plot(xi,fnval(sp,xi),'r');
title('spaps(x,0.01*y,0.01*tol)')
hold off
Why is 'spaps' not scaleable?

 채택된 답변

Andrew Newell
Andrew Newell 2011년 6월 24일

0 개 추천

Interesting question. I don't know anything about the algorithm, but the documentation says that the distance being minimized is a sum of squares, so I thought I'd try
tol = tol*scale^2;
It works, producing a fit that lies on top of the first fit when divided by scale.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by