Merge of Logical Indexing one dimension matrix from multi dimension?

3 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 27 Nov. 2019
all(A)

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by