Extracting data from a matrix

조회 수: 1 (최근 30일)
ieva ashmore
ieva ashmore 2017년 4월 29일
댓글: ieva ashmore 2017년 4월 30일
I have a 50x3 matrix with numerical values. I want to take all the rows that have 2 zeros or more out For example
0 25 15;
0 0 25;
16 13 12
I only want to get out the first and the third row. And I do not wish to do that manually with 50 rows.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2017년 4월 30일
a = [0 25 15;
0 0 25;
16 13 12];
out = a(sum(a == 0,2) < 2,:)
  댓글 수: 1
ieva ashmore
ieva ashmore 2017년 4월 30일
Thank you. That we nice, clean and easy one line solution.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by