# Help with arrays and matrices!

• 02-14-2013, 11:21 PM
chwex
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.

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!
• 02-15-2013, 12:14 AM
Wizard0860
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.
• 02-15-2013, 12:34 AM
chwex
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!