Merge of Logical Indexing one dimension matrix from multi dimension?

4 views (last 30 days)
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.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 27 Nov 2019
all(A)

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!