Effacer les filtres
Effacer les filtres

How do I delete a row in a matrix?

3 vues (au cours des 30 derniers jours)
Lauren
Lauren le 13 Mar 2015
Commenté : Lauren le 13 Mar 2015
Hi!
How would I delete all the rows that have a zero in the second column? For example, if I have the matrix
[1 3;2 0;3 11;4 8;5 0]
how could I delete the two rows containing zeroes to make my matrix look like
[1 3;3 11;4 8]
Thank you!!

Réponse acceptée

James Tursa
James Tursa le 13 Mar 2015
>> a = [1 3;2 0;3 11;4 8;5 0]
a =
1 3
2 0
3 11
4 8
5 0
>> a(a(:,2)==0,:) = []
a =
1 3
3 11
4 8
  1 commentaire
Lauren
Lauren le 13 Mar 2015
Great, thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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