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

1 Ansicht (letzte 30 Tage)
Ali Ali
Ali Ali am 7 Jul. 2019
Kommentiert: Ali Ali am 8 Jul. 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

Akzeptierte Antwort

madhan ravi
madhan ravi am 7 Jul. 2019
use all() for columns and rows separately , make a copy of A to B and finally remove the unwanted
  3 Kommentare
madhan ravi
madhan ravi am 7 Jul. 2019
B = A;
r = all(A,2);
c = all(A,1);
B(r,:) = [];
B(:,c) = []

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 7 Jul. 2019
A=[1 1 1 1; 1 0 1 1;1 0 0 1];
AA = ~A;
B = A(any(AA,2),any(AA));

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