필터 지우기
필터 지우기

How do I delete a row in a matrix?

조회 수: 2 (최근 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 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