Extracting data from a matrix

1 vue (au cours des 30 derniers jours)
ieva ashmore
ieva ashmore le 29 Avr 2017
Commenté : ieva ashmore le 30 Avr 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.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by