How do I delete a row in a matrix?

2 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by