Finding indices of array elements in 3d matrix
Show older comments
Suppose, there is a 3d matrix M.
M(:,:,1) =
Columns 1 through 8
0.4824 0.4824 0.4824 0.4824 0.4863 0.4902 0.4941 0.4941
0.4824 0.4863 0.4863 0.4902 0.4941 0.4980 0.4980 0.5020
0.4824 0.4863 0.4863 0.4902 0.4941 0.4980 0.5020 0.5059
M(:,:,2) =
Columns 1 through 8
0.5412 0.5412 0.5412 0.5412 0.5451 0.5490 0.5529 0.5529
0.5412 0.5451 0.5451 0.5490 0.5529 0.5569 0.5569 0.5608
0.5412 0.5451 0.5451 0.5490 0.5529 0.5569 0.5608 0.5647
M(:,:,3) =
Columns 1 through 8
0.3725 0.3725 0.3725 0.3725 0.3765 0.3804 0.3843 0.3843
0.3725 0.3765 0.3765 0.3804 0.3843 0.3882 0.3882 0.3922
0.3725 0.3765 0.3765 0.3804 0.3843 0.3882 0.3922 0.3961
there is another 2D matrix 'V' having 3 columns of values.
V= 0.482352941176471 0.541176470588235 0.372549019607843
0.490196078431373 0.549019607843137 0.380392156862745
0.478431372549020 0.537254901960784 0.376470588235294
Now, we need to find the indices of all the column values of V in M row wise that appear all together. I have implemented as below.
for pt= 1:length(V)
[x0,y0,z0]=
find(M(:,:,1)==V(pt,1,:)& M(:,:,2)==V(pt,2,:)& M(:,:,3)==V(pt,3,:));
It does not show all the indices in array. But, separately finding x0, y0,z0 works. V need not to be of same dimension. Whoever can guide, please, solve it as soon as possible.
Accepted Answer
More Answers (0)
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!