find index values in a 3D matrix above a threshold
Show older comments
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)
Bjorn Gustavsson
on 11 Mar 2019
Edited: Bjorn Gustavsson
on 11 Mar 2019
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
madhan ravi
on 11 Mar 2019
Edited: madhan ravi
on 11 Mar 2019
why use find? By the way the values are from 0 to 1 , why was >1 when it will return an empty array?
Bjorn Gustavsson
on 11 Mar 2019
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;
Categories
Find more on Matrices and Arrays 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!