반응형
Excel for scientists and engineer - numerical method by E. Joseph Billo
의 미분방정식의 풀이 입니다.
Option Explicit
Function FirstDerivDemo(expression, variable) As Double
'Custom function to return the first derivative of a formula in a cell
Dim OldX As Double, OldY As Double, NewX As Double, NewY As Double
Dim Formulastring As String, XAddress As String
Formulastring = expression.Formula
OldY = expression.Value
XAddress = variable.Address 'Default is absolute reference
OldX = variable.Value
NewX = OldX * 1.00000001
Formulastring = Application.ConvertFormula(Formulastring, xlA1, xlA1, xlAbsolute) 'Convert all references in formula to absolute
Formulastring = Application.Substitute(Formulastring, XAddress, NewX)
NewY = Evaluate(Formulastring)
FirstDerivDemo = (NewY - OldY) / (NewX - OldX)
End Function
반응형
'VBA' 카테고리의 다른 글
엑사남 강의 16강 정렬 sort (0) | 2022.03.10 |
---|---|
VBA에서 만든 함수 #NAME? error (0) | 2022.03.09 |
엑사남 강의 14강 BeforeRightClick event (0) | 2022.03.06 |
엑사남_13강 DoubleClick 이벤트 (0) | 2022.03.05 |
범위를 변수로 지정하는 방법 (0) | 2022.03.01 |