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!