Splines

Carlo de Falco carlo.defalco at gmail.com
Wed Oct 1 05:44:37 CDT 2008


On 01/ott/08, at 10:56, Jaroslav Hajek wrote:

>
> The interp1 functions *are* using splines when you specify "cubic"
> interpolation.
not really, try...

 >> x = sortrows (rand(10,2));
 >> xsp = linspace(min(x(:,1)), max(x(:,1)), 100);
 >> plot(x(:,1),x(:,2),'x', xsp, interp1(x(:,1), x(:,2), xsp,  
'cubic'), xsp,spline(x(:,1), x(:,2), xsp))

I think

spline(x(:,1), x(:,2), xsp)

is rather equivalent to

interp1(x(:,1), x(:,2), xsp, 'spline')

 >> norm (spline(x(:,1), x(:,2), xsp) - interp1(x(:,1), x(:,2), xsp,  
'spline'), inf)
ans = 0

but the spline command gives more control on the boundary slope...

>
> To get a denser sample, you can add
> x = linspace (min(x), max(x), 1000).';
> or something similar after the `x = unique' line.
>
c.



More information about the Help-octave mailing list