タイトル | : Re^2: VB6で配列の中のデータをクリアする方法 |
記事No | : 11389 |
投稿日 | : 2008/02/11(Mon) 21:16 |
投稿者 | : せふぃ |
早速の返事ありがとうございます<(_ _)>ファイルはここにアップしておきました h http://www.mediafire.com/upload_complete.php?id=gz3vt2zg3be この中の回帰直線最終段階というものが該当プログラムです この中の Dim j As Integer Dim gp As Integer Dim gs As Integer Dim rr(20) As Double gs = Val(Text7.Text) gp = Val(Text8.Text)
For j = gs To gp 'rの最適値求めるループ開始xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx qr(800) = 0 qrr(800) = 0 c(800) = 0 d(800) = 0
For i = 0 To datan - 1 c(i) = Val(data(i).hachou) d(i) = Val(data(i).toukaritu) If data(i).toukaritu > 1 Then d(i) = 1 End If Next i
Dim cc(800) As Double '1/波長 と縦軸のαhν^nの値を配列
cc(800) = 0
For i = 0 To datan - 1 cc(i) = 1240 / c(i) Next i For i = 0 To datan - 1 MSFlexGrid1.Row = i + 1 MSFlexGrid1.Col = 5 MSFlexGrid1.Text = Format(cc(i), f1) Next i
For i = 0 To datan - 1 qr(i) = -10 ^ 4 * Log(d(i)) * cc(i) If qr(i) > 0 Then qrr(i) = qr(i) ^ j Else qr(i) = -qr(i) qrr(i) = qr(i) ^ j End If MSFlexGrid1.Row = i + 1 MSFlexGrid1.Col = 4 MSFlexGrid1.Text = Format(qrr(i), "####0.00") Next i
For i = e - 1 To f - 1 h(i) = cc(i) k(i) = qrr(i) Next i
'xに関する平均値と標準偏差の計算プログラム---------------------------------- Dim sx As Double, sxx As Double, avx As Double, sdx As Double Dim x(800) As Double For i = ee - 1 To ff - 1 x(i) = h(i) Next i
sx = 0 sxx = 0 For i = ee - 1 To ff - 1 sx = sx + x(i) sxx = sxx + x(i) * x(i) Next i avx = 0 sdx = 0 avx = sx / m sdx = Sqr((sxx - m * avx * avx) / m)
'yに関する平均値と標準偏差の計算プログラム--------------------------------- Dim sy As Double, syy As Double, avy As Double, sdy As Double Dim y(800) As Double
For i = ee - 1 To ff - 1 y(i) = k(i) Next i sy = 0 syy = 0 For i = ee - 1 To ff - 1 sy = sy + y(i) syy = syy + y(i) * y(i) Next i avy = 0 sdy = 0 avy = sy / m sdy = Sqr((syy - m * avy * avy) / m)
'相関係数 rの値を求める
Dim sxy As Double, r As Double sxy = 0 r = 0 For i = ee - 1 To ff - 1 sxy = sxy + x(i) * y(i) Next i r = ((sxy - m * avx * avy) / m) / (sdx * sdy)
rr(j) = r Next j 'rの最適値求めるループ終了-------------------------------------------------------------------------
この部分なんですが; jのループに囲まれてるところです;
|