• Post Reply Bookmark Topic Watch Topic
  • New Topic

Subtract 3D matrix from 2D  RSS feed

 
nvayin agha
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the code bellow which is for subtracting 3D Matrix from 2D , iam receiving error : Array index out of bound



any help please
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nvayin,

how do you debug your programs?

If you look at the dimensions of the 2D arrays arr1[0] and arr2, you see that arr1[0] is 3 * 4, while arr2 = 2 * 4.
So, you get this error on arr2 in your test method.
 
nvayin agha
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The data that i have have these format:

a[][][]:

3.551777347914275 1.286875832907195
8.513771304610692 3.084699705412586

5.896962960211207 2.1365807531547536
6.477661799763445 2.346978880519314

7.447357702484369 2.6983179708520675
5.156151670042258 1.8681708691221717


and b[][]:

1.4 0.2
1.4 0.2
1.3 0.2
1.5 0.2
1.4 0.2
1.7 0.4
1.4 0.3


those are my data which i should use the method subtract on them
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the look of it, a = 3 x 2 x 2, and b = 7 x 2.
How would you subtract one from the other?

Can you explain what it is you are trying to achieve?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!