find index values in a 3D matrix above a threshold

Hi,
I have two 3D matrices of same size. Say, A contain values ranging from 0 to 1 and B contains certain discreate values.
I want to filter out values above certain threshold from A and use corresponding index values to replot B matrix for further calculation.
Can anyone help me out?

Answers (1)

To find indices to values larger than 1 do:
[i1,i2,i3] = find(A>threshold);
After that you might have to loop over the indices or perhaps you can do your processing with linear indexing. Have a look into sub2ind.
HTH

2 Comments

why use find? By the way the values are from 0 to 1 , why was >1 when it will return an empty array?
Because I was to lazy to type threshold, edited it now to clarify for every level of matlab-user. Find used since it is not clear what further steps the OP wanted to do. Another possibility is:
idx = A(:)>thresh;

Sign in to comment.

Categories

Asked:

on 11 Mar 2019

Commented:

on 11 Mar 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!