Das was du in Sheet 2 ausrechnest, kannst du im Sheet 3 ohne Fließkomma so ausrechnen.
(Beachte den Faktor 1024, um den jeder Wert zu groß ist.)
Code:Public Sub CalculateSheet3Formular() Dim nNoise As Long Dim nEstimation As Long Dim nLastEstimation As Long Dim nPresition As Long Dim nLastPresition As Long Dim nKalmanKoeffizent As Long Dim nADC As Long Dim nTemperatur As Long Dim objWorkbork As Workbook Dim FAKTOR As Long Dim i As Integer Set objWorkbork = ThisWorkbook FAKTOR = 1024 'am besten Potenz von 2 als Faktor (hier: 2^10) nNoise = 2 * FAKTOR / 10 ' enspricht 0,2 * FAKTOR nLastEstimation = 0 nPresition = 1 * FAKTOR For i = 2 To 22 nADC = objWorkbork.Sheets(3).Cells(i, 1).Value nADC = nADC * FAKTOR * 64 nTemperatur = 82 * FAKTOR + nADC nTemperatur = nTemperatur / 101 nTemperatur = nTemperatur - (150 * FAKTOR) objWorkbork.Sheets(3).Cells(i, 2).Value = nTemperatur nLastPresition = nPresition nKalmanKoeffizent = nPresition * FAKTOR / (nPresition + nNoise) nEstimation = (nLastEstimation * FAKTOR + nKalmanKoeffizent * (nTemperatur - nLastEstimation)) / FAKTOR nPresition = ((FAKTOR - nKalmanKoeffizent) * nPresition) / FAKTOR nLastEstimation = nEstimation objWorkbork.Sheets(3).Cells(i, 3).Value = nKalmanKoeffizent objWorkbork.Sheets(3).Cells(i, 4).Value = nPresition objWorkbork.Sheets(3).Cells(i, 5).Value = i - 1 objWorkbork.Sheets(3).Cells(i, 6).Value = nEstimation ' Zu Vergleichszwecken Tabelle mit rückgewandelten Werten: objWorkbork.Sheets(3).Cells(i, 8).Value = CDbl(objWorkbork.Sheets(3).Cells(i, 3).Value) / FAKTOR objWorkbork.Sheets(3).Cells(i, 9).Value = CDbl(objWorkbork.Sheets(3).Cells(i, 4).Value) / FAKTOR objWorkbork.Sheets(3).Cells(i, 10).Value = CDbl(objWorkbork.Sheets(3).Cells(i, 5).Value) / FAKTOR objWorkbork.Sheets(3).Cells(i, 11).Value = CDbl(objWorkbork.Sheets(3).Cells(i, 6).Value) / FAKTOR Next i End Sub







Zitieren

Lesezeichen