hi guys i got this program i am been doing. its a fairly simply program and i am fairly useless in programming. I am beginning to learn program rite now and i am doing this problem
Qn) Develop a general code for multiplying an [m x n] matrix with any [n x k] matrix is
given below. Implement the code in EXCEL VB. Verify the results using hand
calculations.
MATRIX A
1 2 3
3 4 4
2 0 6
MATRIX B
1 2
6 2
4 1
This is what i have done
can u guys see through my code and point out where i have gone wrong.
Thanks in advance
Qn) Develop a general code for multiplying an [m x n] matrix with any [n x k] matrix is
given below. Implement the code in EXCEL VB. Verify the results using hand
calculations.
MATRIX A
1 2 3
3 4 4
2 0 6
MATRIX B
1 2
6 2
4 1
This is what i have done
Code:
Private Sub mycode_Click()
Dim i As Integer, j As Integer, n As Integer
Dim A() As Single, B() As Single, C() As Single
n = Cells(1, 2)
ReDim A(n, n) As Single, B(n, n) As Single, C(n, n) As Single
For i = 1 To n
For j = 1 To n
A(i, j) = Cells(1 + i, j)
Next j
Next i
For i = 1 To n
For j = 1 To n
A(i, j) = Cells(2 + i, j)
Next j
Next i
For i = 1 To n
C(i) = 0#
For j = 1 To n
C(i) = C(i) + A(i, j) * B(j)
Next j
Next i
For i = 1 To n
Cells(2 + i, n + 4) = C(i)
Next i
End Sub
can u guys see through my code and point out where i have gone wrong.
Thanks in advance