Delete rows from matrix?

3 vues (au cours des 30 derniers jours)
Xi Wen Lim
Xi Wen Lim le 26 Mar 2016
Commenté : Xi Wen Lim le 26 Mar 2016
I have a bunch of data:
[1 1
0 0
2 6
3 5
5 55
6 56
0 0
7 69
11 2
0 0 ]
I want to remove all rows with values 0 in the first column. How should I do this? The above is just a part of the data. The data has way more rows than that.

Réponse acceptée

Stephen23
Stephen23 le 26 Mar 2016
Modifié(e) : Stephen23 le 26 Mar 2016
Just use some basic MATLAB logical indexing:
>> X = M(M(:,1)~=0,:)
X =
1 1
2 6
3 5
5 55
6 56
7 69
11 2
  1 commentaire
Xi Wen Lim
Xi Wen Lim le 26 Mar 2016
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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