How to find the indexes of a matrix which has zero elements as well

How to find the indexes of a matrix which can have any number of columns and which has zero elements as well
For Example: A=[1 0 0;0 1 0;0 0 1] (here A has 3 columns) or A =[0 0 0 1; 1 0 0 1;0 0 0 0; 1 1 0 0; 1 1 1 1] (here A has 4 columns)

댓글 수: 3

Which indices would it be you're looking for????
Taking a stab
doc find % comes to mind, maybe??
Thanks for the reply,but find function finds the indices of only non-zero elements
We don't understand what you're looking for. For the second example you posted, what SPECIFICALLY do you want to be returned as the list of "indexes of a matrix" and why did you select those particular elements of the matrix?

댓글을 달려면 로그인하십시오.

답변 (1개)

Thorsten
Thorsten 2015년 10월 28일
It is not entirely clear to me what you want.
The linear indices of a matrix A are
reshape(1:numel(A), size(A))
To find the indices of zeros in A, use
ind = find(A == 0);

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

질문:

2015년 10월 28일

답변:

2015년 10월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by