How do I remove paired data in a matrix?

Let's say I have a matrix,
A =
1 0
-2 -9
3 7
4 -3
-9 10
5 6
How would I be able to filter it out so that both columns are positive numbers? If either column is negative, then you should delete the whole row. The output should be
A =
1 0
3 7
5 6
I am stuck and don't know the direction to go towards. How should I do this? Any help will be appreciated. Thank you!

 Accepted Answer

dpb
dpb on 3 Sep 2018
Edited: dpb on 3 Sep 2018
A(any(A<0,2),:)=[];
Or, vice versa, keep the wanted--
A=A(all(A>=0,2),:); % keeps 0 as +ive
Look up logical indexing

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 3 Sep 2018

Commented:

on 3 Sep 2018

Community Treasure Hunt

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

Start Hunting!