# how to find zero value with find

23 views (last 30 days)
alize beemiel on 1 Feb 2022
Commented: alize beemiel on 1 Feb 2022
BC =[0 0 0
0 1 0
0 0 0
0 0 1
1 1 1
0 0 1
0 0 0
0 1 0
0 0 0]
U=1-BC
f=find(U);
and f is
f =[1 2 3 4 6 7 8 9 10 12 13 15 16 18 19 20 21 25 26 27]
but I was confused because it's clear that the exact value is
and this is what I want to have
i_want=[1 2 3 4 6 7 8 9 10 11 16 17 19 20 21 22 24 25 26 27]
Can someone help me Where is my mistake?

Image Analyst on 1 Feb 2022
Try this. It will give you two vectors, rows and columns, which are the row and column location that the corresponding zero can be found at in the original matrix.
BC =[0 0 0
0 1 0
0 0 0
0 0 1
1 1 1
0 0 1
0 0 0
0 1 0
0 0 0];
[rows, columns] = find(BC == 0)
rows = 20×1
1 2 3 4 6 7 8 9 1 3
columns = 20×1
1 1 1 1 1 1 1 1 2 2
alize beemiel on 1 Feb 2022
thank you sir
very interesting all of this

Turlough Hughes on 1 Feb 2022
Try the following:
find(BC==0)
or
find(~BC)
alize beemiel on 1 Feb 2022
all this informations are very helpfull
thanks very much

Les Beckham on 1 Feb 2022
Edited: Les Beckham on 1 Feb 2022
Matlab will index down the columns first. It appears that you want to go across the rows first.
So, just transpose the matrix.
BC =[0 0 0
0 1 0
0 0 0
0 0 1
1 1 1
0 0 1
0 0 0
0 1 0
0 0 0];
i_want = find(BC' == 0)'
i_want = 1×20
1 2 3 4 6 7 8 9 10 11 16 17 19 20 21 22 24 25 26 27
##### 2 CommentsShowHide 1 older comment
alize beemiel on 1 Feb 2022
oh
thank you very much
so easy ..
thanks very much

### Categories

Find more on Resizing and Reshaping Matrices 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!

Translated by