Finding the nonzero element in a specific row
조회 수: 1 (최근 30일)
이전 댓글 표시
If i have a matrix and i want to find the indices of a non zero elements in a specific row only how can i do that ?
댓글 수: 0
답변 (2개)
Star Strider
2019년 7월 18일
Select the row, then use find:
A = [1 3 0; 2 0 4; 0 7 9]
DesiredRow = 2
cix = find(A(DesiredRow,:) ~= 0)
so:
A =
1 3 0
2 0 4
0 7 9
DesiredRow =
2
cix =
1 3
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!