remove rows with all zeros

92 Ansichten (letzte 30 Tage)
Rahul
Rahul am 6 Jun. 2012
Kommentiert: Shishir Bapat am 11 Mär. 2021
I have
a =
1 2 3
0 0 0
2 1 0
4 5 0
0 0 0
2 0 1
I need
b=
1 2 3
2 1 0
4 5 0
2 0 1

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Jun. 2012
b = a(any(a,2),:);
  5 Kommentare
Mohamed Nedal
Mohamed Nedal am 20 Dez. 2019
Hi Walter,
Would you please explain this line?
b = a(any(a,2),:);
Shishir Bapat
Shishir Bapat am 11 Mär. 2021
Thank you

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Geoff
Geoff am 6 Jun. 2012
Search facility on Answers shows this question is asked a lot... Here's one of the more recent.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by