Merge of Logical Indexing one dimension matrix from multi dimension?

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 27 de Nov. de 2019
all(A)
  1 comentario
Lin Nuo
Lin Nuo el 27 de Nov. de 2019
Editada: Lin Nuo el 27 de Nov. de 2019
oo my God. Awesome. Out of my mind. :D. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by