ShelleyBelly
New Member
- Joined
- Mar 2, 2011
- Messages
- 44
Hi There,
Not sure if i'm asking the impossible but think i might just be.
i'm making a UDF and the algebra requires going to the Nth term, so instead of writing the same section of the formula over again i've written the architecture of it and then incorporated that as a UDF inside the former.
My question is, as the second UDF will only be used in conjunction with the first, is it possible to write it inside the first UDF.
Sorry for the poor explanation. Basically can you put a function inside another as below, or must they be separate??
Cheers
Function MP(Lat1)
'a = 6378137 ' Part of the WGS-84
'b = 6356752.3142 ' ellipsiod datum
f = 1 / 298.257223563
Lat1 = Radians(Lat1)
a = 21600 / (2 * Pi)
e = (2 * f - f ^ 2) ^ 0.5
Function Nth(n, Lat1)
Nth = e ^ (n + 1) / n * Sin(Lat1) ^ n
End Function
MP = a * Log(10) * Log10(Tan(Radians(45) + Lat1 / 2)) - a * (Nth(1, Lat1) + Nth(3, Lat1) + Nth(5, Lat1) + Nth(7, Lat1) + Nth(9, Lat1) + Nth(11, Lat1))
End Function
Not sure if i'm asking the impossible but think i might just be.
i'm making a UDF and the algebra requires going to the Nth term, so instead of writing the same section of the formula over again i've written the architecture of it and then incorporated that as a UDF inside the former.
My question is, as the second UDF will only be used in conjunction with the first, is it possible to write it inside the first UDF.
Sorry for the poor explanation. Basically can you put a function inside another as below, or must they be separate??
Cheers
Function MP(Lat1)
'a = 6378137 ' Part of the WGS-84
'b = 6356752.3142 ' ellipsiod datum
f = 1 / 298.257223563
Lat1 = Radians(Lat1)
a = 21600 / (2 * Pi)
e = (2 * f - f ^ 2) ^ 0.5
Function Nth(n, Lat1)
Nth = e ^ (n + 1) / n * Sin(Lat1) ^ n
End Function
MP = a * Log(10) * Log10(Tan(Radians(45) + Lat1 / 2)) - a * (Nth(1, Lat1) + Nth(3, Lat1) + Nth(5, Lat1) + Nth(7, Lat1) + Nth(9, Lat1) + Nth(11, Lat1))
End Function