필터 지우기
필터 지우기

Find 1's each Row

조회 수: 1 (최근 30일)
Hello kity
Hello kity 2013년 1월 30일
I have an easy question;
I have a matrix ( x row, x columns) filled with 0s and 1s.
I want to check if there is a 1 in every row (for every column).
then result that in a new matrix
so basically it is this
0 0 0 = 0
1 0 0 = 1
0 1 0 = 1
0 0 1 = 1
  댓글 수: 3
Image Analyst
Image Analyst 2013년 1월 30일
Not that it matters, but you don't have x rows and x columns - your matrix is not square. Plus your answer does not check for a 1 in every row for every column. That would be an array that is completely all 1's. You don't even check for 1's in every column. You're just checking each row if there is a 1, which is quite different. Plus we don't even know if you need exactly one 1, or if multiple 1's should also produce a 1 for that row in your output vector.
Hello kity
Hello kity 2013년 1월 30일
I can only get a single 1 at each row, that is how my data is buildup.

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

채택된 답변

Image Analyst
Image Analyst 2013년 1월 30일
oneInColumn = any(yourMatrix, 2);

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by