Function like "find" but for lines
5 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone, I need a function that starts counting every element in an array (each line), and when it finds 0, it can skip it.
ex: A = [6 5 0 1; 3 1 0 0; 12 0 100 20]
newA = [ 1 2 4 5 6 9 11 12]
I was trying something like this:
k = 0;
colind = 1:numel(A);
colind(A!=k)
But it only takes me each column in the matrix.
wrong: newA = [1 2 3 4 5 9 10 12]
I want to count my elements on each line of the matrix. A little help please! :)
0 件のコメント
採用された回答
その他の回答 (2 件)
Ameer Hamza
2020 年 4 月 7 日
編集済み: Ameer Hamza
2020 年 4 月 7 日
new_A = find(A')
2 件のコメント
Ameer Hamza
2020 年 4 月 7 日
編集済み: Ameer Hamza
2020 年 4 月 7 日
The functionality of find function is the same, so
[new_A,~] = find(A');
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!