Re: Exponetial Interpolation VBA Code
- From: dougaj4@xxxxxxxxx
- Date: Fri, 10 Aug 2007 23:55:31 -0700
On Aug 8, 6:18 am, David B <da...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
You (as well as dougaj4) also make (IMO) goofy implicit
assumptions about the nature of the objects/arrays being passed in, as
well as some inefficient "dims".
David B, feel free to tell which implicit assumptions are goofy, and
why, and show us how to make the "dims" more efficient.
More to the point, the formula given in the OP gives the wrong
answers.
The code below will I believe give correct exponential interpolation:
Function ExpInterp2(D As Variant, P As Variant, V As Double) As
Variant
Dim i As Long, LogP As Double, LogPdiff As Double, Dprev As Double
Dim DDiff As Double, Logslope As Double, LogInterp As Double
If TypeName(D) = "range" Then D = D.Value
If TypeName(D) = "range" Then P = P.Value
i = 1
Do While V > D(i, 1)
i = i + 1
Loop
i = i - 1
LogP = Log(P(i, 1))
LogPdiff = Log(P(i + 1)) - LogP
Dprev = D(i, 1)
DDiff = D(i + 1, 1) - Dprev
Logslope = LogPdiff / DDiff
LogInterp = LogP + (V - Dprev) * Logslope
ExpInterp2 = Exp(LogInterp)
End Function
Goofy implicit assumptions are that D and P are single column ranges
containing values, and V is a value or a cell address containing a
value.
.
- Follow-Ups:
- Re: Exponetial Interpolation VBA Code
- From: rombonacho
- Re: Exponetial Interpolation VBA Code
- References:
- Re: Exponetial Interpolation VBA Code
- From: rombonacho
- Re: Exponetial Interpolation VBA Code
- From: David B
- Re: Exponetial Interpolation VBA Code
- Prev by Date: Re: Exponetial Interpolation VBA Code
- Next by Date: Re: Exponetial Interpolation VBA Code
- Previous by thread: Re: Exponetial Interpolation VBA Code
- Next by thread: Re: Exponetial Interpolation VBA Code
- Index(es):
Relevant Pages
|