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

1 vue (au cours des 30 derniers jours)
Ali Ali
Ali Ali le 7 Juil 2019
Commenté : Ali Ali le 8 Juil 2019
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

Réponse acceptée

madhan ravi
madhan ravi le 7 Juil 2019
use all() for columns and rows separately , make a copy of A to B and finally remove the unwanted
  3 commentaires
madhan ravi
madhan ravi le 7 Juil 2019
B = A;
r = all(A,2);
c = all(A,1);
B(r,:) = [];
B(:,c) = []
Ali Ali
Ali Ali le 8 Juil 2019
thank you

Connectez-vous pour commenter.

Plus de réponses (1)

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

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by