MATLAB Answers

Ali Ali
0

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

Asked by Ali Ali
on 7 Jul 2019
Latest activity Commented on by Ali Ali
on 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

  0 Comments

Sign in to comment.

2 Answers

Answer by madhan ravi
on 7 Jul 2019
 Accepted Answer

use all() for columns and rows separately , make a copy of A to B and finally remove the unwanted

  3 Comments

I tried but could not find the result
If you have the code, I hope you send it
B = A;
r = all(A,2);
c = all(A,1);
B(r,:) = [];
B(:,c) = []

Sign in to comment.


Answer by Andrei Bobrov
on 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));

  0 Comments

Sign in to comment.