I have a question and I hope it is not duplicate.
First, I have let say the following matrix:
A=[2 2 2 0 0
1 2 3 0 0
4 5 7 2 0]
I want to remove the zeros from A and return:
A=[2 2 2
1 2 3
4 5 7]
When I do
A(A==0)=[]
I get
A=[2 2 2 1 2 3 4 5 7]
Second, if instead of zeros I want to remove the elements that are greater than something. For example if I want to remove all elements greater than 6 (>6) of the following matrix B:
B=[2 2 2 5 3
1 2 3 6 8
4 5 7 2 1]
I get
A=[2 2 5
1 2 6
4 5 2]
P.S. I know how to do it using loops.
A(:,find(all(A,1)))
– DivakarB(:,~any(B>6,1))
– Divakar