Results 1 to 3 of 3
  1. #1
    chwex is offline Member
    Join Date
    Feb 2013
    Posts
    4
    Rep Power
    0

    Default Help with arrays and matrices!

    I need to multiply two matrices. One has the values interger 0-10 where the values were created randomly and the other one has double values. Both are the same size of 5x31. If I go ahead and print them they look like they have been generated right. This is what I have so far.

    Java Code:
    i = preciomatriz.length;
     j = ranarray.length;
           for(x=0; x<i; x++){
               for(y=0; y<=j; y++){
                   for ( z=0; z<=j; z++) {
                      ventasxdia[x][y] += (double)(preciomatriz[x][z]*ranarray[z][y]); 
                       System.out.println(ventasxdia[x][y]+" ");
                   }                 
                }
            }
    If there is an easier approach to this let me know. I've been looking around for a bit and i can't get it to work! Thanks in advance!

  2. #2
    Wizard0860 is offline Member
    Join Date
    Nov 2012
    Posts
    29
    Rep Power
    0

    Default Re: Help with arrays and matrices!

    idk about a way to do this, but looks to me that 5x31 and 5x31 matrices wouldn't normally multiple with each other. 5x31 and 31x5 would, because rows of 1st= columns of 2nd. if this is different in arrays, my apologies.

  3. #3
    chwex is offline Member
    Join Date
    Feb 2013
    Posts
    4
    Rep Power
    0

    Default Re: Help with arrays and matrices!

    That's what i was thinking too, but there were some examples I found were people would do it directly how I just stated. Thanks for the response though!

Similar Threads

  1. Help with arrays and matrices!
    By chwex in forum New To Java
    Replies: 3
    Last Post: 02-13-2013, 12:46 PM
  2. Arrays and Matrices
    By Shaeman111 in forum New To Java
    Replies: 2
    Last Post: 11-10-2012, 08:24 AM
  3. how to add columns from Matrices(2D array)
    By John_shok in forum New To Java
    Replies: 7
    Last Post: 10-04-2010, 05:33 PM
  4. Read two matrices from file
    By zenitis in forum New To Java
    Replies: 13
    Last Post: 05-20-2010, 04:03 AM
  5. How to multiply two matrices
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:50 PM

Posting Permissions

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