フィルターのクリア

How can I remove an entire row of zeros in a matrix?

1 回表示 (過去 30 日間)
Dario
Dario 2018 年 3 月 8 日
編集済み: David Fletcher 2018 年 3 月 8 日
If I have a matrix like this one:
45 23 54
0 0 0
9 3 32
How can I remove the second row and obtain this matrix?
45 23 54
9 3 32

採用された回答

David Fletcher
David Fletcher 2018 年 3 月 8 日
編集済み: David Fletcher 2018 年 3 月 8 日
a=[45 23 54;0 0 0;9 3 32];
zero=a==0;
ind=all(zero,2);
a(ind,:)=[]
Presumably the entire row has to have zero in every column for it to be removed

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by