MATLAB Answers

mr mo

How can I subtracting the members of a 3D Matrix ?

Asked by mr mo
on 4 Dec 2016
Latest activity Edited by mr mo
on 8 Dec 2016
Hello every one. I have a 3D matrix of size
every member of this matrix is a random number between 1 to 5 like
I want to subtract each members of matrix A from the 9 overlaying members of it.
but my question is how can i do this procedure for the members that have 4, 5 or 6 overlaying members.
for example member of index (i,j,k)=(1,1,2) that has only 4 overlaying members in z=1 and this code is not useful in this situation because this code working in cases that there are only 9 overlaying members.
In fact for
in all pages from z=2 to z=10 this code is not useful and I am very confused because these members have 4 or 6 overlaying members . with best regards.


Sign in to comment.

1 Answer

Answer by Image Analyst
on 5 Dec 2016

Use convn() with the proper kernel. But I'm not really sure what you mean by overlaying members and what's going on with the z=1 plane.


Show 1 older comment
OK, so you have a 10*10*10 3D matrix with 1000 elements in it.
You say " I want to subtracting the members of the 3D Matrix from" <== OK that means you want to subtract 1000 elements from something.
Then you say "from 9 overlaying member which is above it" OK, this means that you want to subtract 1000 elements from 9 elements. You can only subtract the same number of elements or a single elements. So you can subtract 1000 numbers from the corresponding 1000 numbers or you can subtract 9 numbers from 9 numbers, OR you can subtract 1 number from all 1000 elements, or subtract 1 number from 9 elements. I'm not sure what you want to do. But I know you can't subtract 1000 elements from 9 elements, like "out = vector9x1 - vector1000x1" <== that's not allowed.
Hi again. if you can get me your Email address then I can email you some pictures that clearly explain what I'm gonna do. With Best Regards.
Best, is to attach these image in the post rather than emailing them to one single person. That way you can get other people input as well.

Sign in to comment.