Thread: Cubic splines
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default Cubic splines

Eric. Just for feedback, David's code works really well! For example, he
gave 7 data points for testing, with x values running from 1-7.
As a custom function, the Cubic Spline equations of that test data would be
the following: The returned values match David exactly. :)

Function Spline(num)
Dim t, n
n = num - Int(num)

Select Case num
Case Is < 1
t = "#N/A"
Case Is < 2
t = 3 + (21 * n) / 26 - (21 * n ^ 3) / 26
Case Is < 3
t = 3 - (21 * n) / 13 - (63 * n ^ 2) / 26 + (53 * n ^ 3) / 26
Case Is < 4
t = 1 - (9 * n) / 26 + (48 * n ^ 2) / 13 - (61 * n ^ 3) / 26
Case Is < 5
t = 2 - (87 * n ^ 2) / 26 + (61 * n ^ 3) / 26
Case Is < 6
t = 1 + (9 * n) / 26 + (48 * n ^ 2) / 13 - (53 * n ^ 3) / 26
Case Is <= 7
t = 3 + (21 * n) / 13 - (63 * n ^ 2) / 26 + (21 * n ^ 3) / 26
Case Else
t = "#N/A"
End Select

Spline = t
End Function


--
Dana DeLouis
Win XP & Office 2003


"Eric Desart" wrote in message
...
Hello Debra,

A million thanks .... that one works.

I tried again in Ron de Bruyn's Google search and via Google.com by
literally copying text from the David Braden post as text and they
couldn't
find it.

You helped me a lot.
And thanks to David to.

Kind regards
Eric

PS: maybe an idea for David to reenter that post that google.com can find
it
too. (it's often referred to).



"Debra Dalgleish" wrote in message
...
Try this link instead:


http://groups.google.ca/groups?selm=...chester.rr.com

Eric Desart wrote:
Sorry all,

A dumb question.
I was searching the Excel groups for a Cubic spline smoothing.

I find numerous messages refering to code entered by David Braden.
In some I find a link:

Most (all?) look like this:

http://groups.google.com/groups?selm...chester.rr.com

But this leads nowhere.

Can somebody help me locating this code?
I really tried myself.

TIA
Eric




--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html