I have a matrix B B(:,:,1) =
2 8 0 5
B(:,:,2) =
1 3 7 9 I want to find the index of a value close e.g. to 2.9. in each column. I tried the following code: [r,c,v] = ind2sub(size(B),find(min(abs(B-2.9)))); I get:
r =
1 2 1 2 c = 1 1 2 2 v = 1 1 1 1
What I want is:
r = 1,2,1,1 c = 1,2,1,2 v = 1,1,2,2
Best Answer