Merge of Logical Indexing one dimension matrix from multi dimension?

조회 수: 4 (최근 30일)
Lin Nuo
Lin Nuo 2019년 11월 27일
편집: Lin Nuo 2019년 11월 27일
A = [
0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 0 0 0 1 1 1 0 0 ;
0 0 0 1 1 0 0 1 1 1 1 0 1 1 0 0 0 1 0 0 1 0 1 0 0 ;
0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 0 0 ;
0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 0 0 1 0 0 0 1 1 0 0 ;
0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 1 1 1 0 0];
Can we only extract existing values of 1 from many rows? For examples the result is:
Result = [
0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 1 0 0];
Only one row. Without looping and IF.
*note: The matrix A is only for display. We can copy and paste, but need to adjust the matrix.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 11월 27일
all(A)
  댓글 수: 1
Lin Nuo
Lin Nuo 2019년 11월 27일
편집: Lin Nuo 2019년 11월 27일
oo my God. Awesome. Out of my mind. :D. Thank you.

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

추가 답변 (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