Extracting data from a matrix

1 Ansicht (letzte 30 Tage)
ieva ashmore
ieva ashmore am 29 Apr. 2017
Kommentiert: ieva ashmore am 30 Apr. 2017
I have a 50x3 matrix with numerical values. I want to take all the rows that have 2 zeros or more out For example
0 25 15;
0 0 25;
16 13 12
I only want to get out the first and the third row. And I do not wish to do that manually with 50 rows.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 30 Apr. 2017
a = [0 25 15;
0 0 25;
16 13 12];
out = a(sum(a == 0,2) < 2,:)
  1 Kommentar
ieva ashmore
ieva ashmore am 30 Apr. 2017
Thank you. That we nice, clean and easy one line solution.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by