What is an alternative FIND function that find indices and values of both ZERO and NONZERO elements in Matlab ?
이전 댓글 표시
Hello,
I am using Matlab and I would like to know how to find indices/values of both zero and nonzero elements of a given vector ? Can anyone help ?
For example:
X = [1 0 2; 0 1 1; 0 0 4];
How can I find indices of the elements in the first raw i.e. '1'; '0'; '2' ?
Thank you!
댓글 수: 3
Walter Roberson
2016년 2월 2일
You want to know the indices of everything together regardless of the respective value? Or you want two outputs, one for the non-zero values and one for the zero values?
Are you looking for linear indices or for row and column indices?
Kirby Fears
2016년 2월 2일
채택된 답변
추가 답변 (1개)
Image Analyst
2016년 2월 3일
Try this:
X = [1 0 2; 0 1 1; 0 0 4]
[zeroRows, zeroColumns] = find(X == 0)
[nonZeroRows, nonZeroColumns] = find(X ~= 0)
카테고리
도움말 센터 및 File Exchange에서 Time Series Events에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!