Home /
Expert Answers /
Computer Science /
how-to-use-vba-customize-function-to-solve-matrix-multiplication-by-using-ubound-use-loops-to-crea-pa733
(Solved): how to use VBA customize function to solve matrix multiplication by using ubound
Use loops to crea ...
how to use VBA customize function to solve matrix multiplication by using ubound
Use loops to create a matrix multiplication. Sub vecMatMult() Function MyMatMult(vec, mat) 'Rnd is a random draw from 0 to 1 'm= Round ( Rnd ?5,0)+1 'n=Round(Rnd?5,0)+1 '> 'ReDimmat(m,n) As Integer ReDim vec(m) As Integer n= ubound(vec, 1) redim out(n) as double For i=0 To m MyMatMult =0?< Return the answer, not 0> For j=0 To nmat(i,j)=i?3+j+1 End Function Next j Next i ' Notice the use of ubound to discover the size of the vector. 'Notice the use of ubound to discover ths size of the matrix. For i=0 To mvec(i)=i+1 Next i out = MyMatMult(vec, mat) End Sub