1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Sub correction_ipi()'-----Déclaration variable-----
Dim x
Dim y
Dim xsq
Dim polynome
Dim yc(4)
Dim Da As Double
Dim Db As Double
Dim Cor As Double
Dim i As Single
Dim j As Single
Dim n As Single
Dim r² As Double
Dim LimiteR² As Double
'-----------------------------
'-----Suppression des anciennes valeurs-----
Cells(23, 14).Value = ""
Cells(26, 30).Value = ""
Cells(28, 30).Value = ""
'-----------------------------
If Cells(26, 1).Value = "" Or Cells(34, 16).Value = "" Or Cells(36, 16).Value = "" Or Cells(38, 16).Value = "" Or Cells(40, 16).Value = "" Or Cells(42, 16).Value = "" Or Cells(44, 16).Value = "" Then Exit Sub 'S'il n'y l'anneau n'a pas été sélectionné ou pas de valeur pour les enfoncements à 1. 25 à 7.5 la macro s'arrêtant
'-----Configuration des variables-----
limitR² = 0.99 'Détermine la limite acceptable de R²
j = 34
'-----------------------------
'-----Récupération des données-----
Debug.Print "Données récupérées" & Chr(10) & "x = y"
Dim nbValeurs
nbValeurs = 8
ReDim x(1 To nbValeurs, 1 To 1)
ReDim y(1 To nbValeurs, 1 To 1)
For i = 1 To nbValeurs Step 1 'Boucle permettant de récupérer les valeurs
If Cells(j, 16).Value <> "" Then
x(i, 1) = Cells(j, 3).Value
y(i) = Cells(j, 16).Value
j = j + 2
Debug.Print x(i, 1) & " = " & y(i)
End If
Next i
'-----------------------------
'-----Analyse & ajustement la courbe du ²-----
xsq = x
ReDim Preserve xsq(1 To UBound(xsq), 1 To 2)
'on calcule x au carré
For i = 1 To UBound(xsq)
xsq(i, 2) = xsq(i, 1) * xsq(i, 1)
Next i
polynome = Application.WorksheetFunction.LinEst(y, xsq, True, True)
a = polynome(1, 1) 'a
b = polynome(1, 2) 'b
c = polynome(1, 3) 'c
r² = polynome(3, 1) 'r²
Debug.Print "a = " & Round(a, 10)
Debug.Print "b = " & Round(b, 10)
Debug.Print "c = " & Round(c, 10)
Debug.Print "r² = " & Round(r², 10) |
Partager