how can remove the rows and columns which has ones in all

1 visualizzazione (ultimi 30 giorni)
if the input array A i want B is the output
A=[1 1 1 1; 1 0 1 1;1 0 0 1]
A =
1 1 1 1
1 0 1 1
1 0 0 1
B =
0 1
0 0
thanks

Risposta accettata

madhan ravi
madhan ravi il 7 Lug 2019
use all() for columns and rows separately , make a copy of A to B and finally remove the unwanted

Più risposte (1)

Andrei Bobrov
Andrei Bobrov il 7 Lug 2019
A=[1 1 1 1; 1 0 1 1;1 0 0 1];
AA = ~A;
B = A(any(AA,2),any(AA));

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by