How do I delete a row in a matrix?

3 ビュー (過去 30 日間)
Lauren
Lauren 2015 年 3 月 13 日
コメント済み: Lauren 2015 年 3 月 13 日
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!!

採用された回答

James Tursa
James Tursa 2015 年 3 月 13 日
>> 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 件のコメント
Lauren
Lauren 2015 年 3 月 13 日
Great, thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by