MATLAB: Could you please tell me algorithm how to chose numbers in a matrix which is sastified a condition

algorithm how to chose numbers in a matrix

for example,i have a matrix a=|1 2 3;3 4 6;8 9 13| i want to chose value numbers between 2 and 5, so i get a12=2;a13=3;a21=3;a22=4;I also know the address of number. But with large matrix, how to get? thanh you so much

Best Answer

Luc, use
a = [1 2 3;3 4 6;8 9 13];
[row col] = find(a>= 2 & a<=5);
which will give you the row and colum indices of the numbers you are looking for. To filter out the individual values and assign them to a new matrix, you could use
aa = a(find(a>= 2 & a<=5));