Berikut merupakan langkah-langkah membuat Invers,Kali & Matriks Pada Ms.Excel :
- buka Ms.Excel
- masukan angka-angka seperti gambar berikut ini :
( masukan angka yang "SOAL" saja )
- masukan coding :
Sub Invers()
Dim A(10, 10)
'BACA DATA
For I = 1 To Cells(1, 2)
For J = 1 To Cells(1, 2)
A(I, J) = Cells(2 + I, 1 + J)
Next J
Next I
'INVERS
For I = 1 To Cells(1, 2)
b = A(I, I)
A(I, I) = 1
For J = 1 To Cells(1, 2)
A(I, J) = A(I, J) / b
Next J
For K = 1 To Cells(1, 2)
If (K <> I) Then
t = A(K, I)
A(K, I) = 0
For x = 1 To Cells(1, 2)
A(K, x) = A(K, x) - A(I, x) * t
Next x
End If
Next K
Next I
'CETAK
For I = 1 To Cells(1, 2)
For J = 1 To Cells(1, 2)
Cells(12 + I, 1 + J) = A(I, J)
Next J
Next I
End Sub
Sub kali()
Dim A(10, 10), b(10, 10), c(10, 10)
For I = 1 To Cells(1, 2)
For J = 1 To Cells(1, 2)
A(I, J) = Cells(2 + I, 1 + J)
b(I, J) = Cells(12 + I, 1 + J)
Next J
Next I
For I = 1 To Cells(1, 2)
For J = 1 To Cells(1, 2)
c(I, J) = 0
For K = 1 To Cells(1, 2)
c(I, J) = c(I, J) + A(I, K) * b(K, J)
Next K
Cells(19 + I, 1 + J) = c(I, J)
Next J
Next I
End Sub
0 komentar:
Posting Komentar