[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What did I do wrong with this funtion? - Implementing msplines and ispli
From: |
Corrado |
Subject: |
What did I do wrong with this funtion? - Implementing msplines and isplines in Octave |
Date: |
Wed, 16 Sep 2009 09:10:37 +0100 |
User-agent: |
KMail/1.11.4 (Linux/2.6.28-13-generic; KDE/4.2.4; x86_64; ; ) |
Dear friends,
I am trying to implement in Octave the two spline families as in the
documentation here below attached. I am a newbie to Octave, and this is my
first function.
I built the function:
function retspline = mspline (i,x,k,t)
# i is the spline index in the family
# x is the variable
# t is the vector of knots, t(h) is the h-th knot
# k is the Mspline degree
I=i
if(k==1)
if(x<t(i+1) & x>=t(i))
td=t(i+1)-t(i)
M=1/td
else
M=0
endif
else
kk=(k-1)
if (x>=t(i) & x<t(i+k))
M=k*((x-t(i))*mspline(i=I,x=x,k=kk,t=t)+(t(i+k)-
x)*mspline(i=(I+1),x=x,k=kk,t=t))/((k-1)*(t(i+k)-t(i)))
elseif (x<t(i) | x>=t(i+k))
M=0
endif
endif
retspline=M
endfunction
but for some reason it does not work ....
I add that I am a newbie with Octave, please do not shut me.
What did I do wrong?
Best,
--
Corrado Topi
Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: address@hidden
mspline
Description: PNG image
ispline.png
Description: PNG image
- What did I do wrong with this funtion? - Implementing msplines and isplines in Octave,
Corrado <=