hello musss1
the error occurs in the Sub PORT, a subscript out of range occurs
I inserted some print statements
this is the output

the error occurs in the Sub PORT, a subscript out of range occurs
I inserted some print statements
Code: (Select All)
Sub PORT (A, B, P, AK) Static
Shared ABX(), BX(), AKA(), PA
X1 = (P / PA) ^ (1 / 7)
BX1 = B / X1
If AK > .95 Then AK = .95
If BX1 < .6 Then BX1 = .6
I = Int(AK / .05) + 1
J = Int((BX1 - .6) / .02) + 1
Print "AK="; AK, "I="; I
Print "J="; J
RA = (AK - AKA(I)) / (AKA(I + 1) - AKA(I))
AB1 = RA * (ABX(I + 1, J + 1) - ABX(I, J + 1)) + ABX(I, J + 1)
AB2 = RA * (ABX(I + 1, J) - ABX(I, J)) + ABX(I, J)
RB = (BX1 - BX(J)) / (BX(J + 1) - BX(J))
ABX1 = RB * (AB1 - AB2) + AB2
A = 2 * X1 * ABX1 - B
End Sub
this is the output
Quote:AK= .9 I= 18in the fifth call to Sub PORT AK and I are NaN, you obviously need to investigate why that happens
J= 21
AK= .95 I= 19
J= 21
AK= .9 I= 18
J= 18
AK= 5.346714E-02 I= 2
J= 12
AK= nan I= nan
J=18