Results 1 to 4 of 4

Thread: Help !!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    9

    Help !!!

    I need to divide one matrix by another like this:

    M1 = [ 0.05 0.02
    0.07 0.12]

    M2 = [1.26 2.35
    0.59 5.04]

    M3 = M2 / M1

    I tried to define M1 and M2 as Val, but the answer is division by zero.
    I think when e define M1 as Val all numbers after the dot got lost.
    How can i threat textmatrix to become double numbers?

    Thanks

  2. #2
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    Re: Help !!!

    Try like this

    Sub main()
    Dim M1
    Dim M2
    Dim M3

    M1 = Array(0.05, 0.02, 0.07, 0.12)
    M2 = Array(1.26, 2.35, 0.59, 5.04)

    For i = 0 To 3
    M3 = M2(i) / M1(i)
    Debug.Print M3
    Next

    End Sub
    Thanks
    Raj

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    9

    Re: Help !!!

    Good thiru,
    but my array is 2 rows x 2 cols
    its a 2x2 matrix
    it must give me back a 2x2 matrix !
    do you know how?

  4. #4
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    Re: Help !!!

    This may help you

    Sub main()

    Dim i, j As Long
    Dim MyAr1(2, 2)
    Dim MyAr2(2, 2)

    MyAr1(1, 1) = 0.125
    MyAr2(1, 1) = 0.125

    MyAr1(1, 2) = 0.25
    MyAr2(1, 2) = 0.5

    MyAr1(2, 2) = 0.25
    MyAr2(2, 2) = 0.25

    MyAr1(2, 1) = 0.625
    MyAr2(2, 1) = 0.625

    For i = 1 To 2
    For j = 1 To 2
    Debug.Print MyAr1(i, j) / MyAr2(i, j)
    Next
    Next

    End Sub
    Thanks
    Raj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width