how to select certain elements from a matrix?

2 views (last 30 days)
Uet
Uet on 11 Jun 2014
Commented: Uet on 11 Jun 2014
A=[1,2,3,4], B=[90,0,40,0;0,0,10,60;55,15,0,10;0,15,5,0]
Hi everyone.. I want to select indexes of only one zero from each row and respective column. please help me in writing matlab code for this problem. Thanks in Advance

Accepted Answer

David Sanchez
David Sanchez on 11 Jun 2014
B=[90,0,40,0;
0,0,10,60;
55,15,0,10;
0,15,5,0];
[col row]=find(B==0);
A= [row col] % coordinates of your zero-elements
A =
1 2
1 4
2 1
2 2
3 3
4 1
4 4
  3 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!