'我想在主程序中使用以下常量调用此函数dpdxf,但它在第一次迭代期间停止,给出-d值为dpdxf。胸围dpdxf总是应该> 0或正。
p1=40196684
p2=4019668
xf=320
PI=4*10^-11
t=20
n=0.4
k=20
wg=3*10^-6
H=46
w=0.006
qg=0.002
mug_p=0.04
'===================================================================
Function dpdxf(p1, p2, xf, PI, t, n, k, wg, H, w, qg, mug_p)
Static frpr
dpdxf = (p1 - p2 - 2 * qg / PI) / xf
FrGaF = 1
Static qgg
Do
frpr = dpdxf
Do
qgg = FrGaF
FrGaF = -((H * wg * (-3 * 2 ^ (-1 / n) * k * n ^ (2 + 1 / n) * ((-2 * t + dpdxf * wf) / (k * n)) ^ (1 + 1 / n) - (2 * dpdxf ^ 2 * wg ^ 2) / (mug_p) - (2 *n * dpdxf ^ 2 * wg ^ 2) / (mug_p))) / (3 * (1 + n) * dpdxf))
Loop While Abs(FrGaF - qgg) >= 0.00
dpdxf = (p1 - p2 - 2 * (FrGaF / PI)) / xf
Loop Until Abs(dpdxf - frpr) <= 0.0001
End Function
答案 0 :(得分:0)
尝试
Function dpdxf(ByVal p1 as Double, ByVal p2 as Double, ByVal xf as Double, ByVal PI as Double, _
ByVal t as Double, ByVal n as Double, ByVal k as Double, ByVal wg as Double, _
ByVal H as Double, ByVal w as Double, ByVal qg as Double, ByVal mug_p as Double)
所以你不会最终划分整数值。同时将常量更改为1#
或2#
,以将它们声明为浮点数。