how to clean data by deleting [0 0]

1 view (last 30 days)
abdullah al-dulaimi
abdullah al-dulaimi on 30 Jun 2022
Edited: Jonas on 30 Jun 2022
I have a data AB=[1 2
3 4
5 6
0 7
8 0
0 0
9 0
0 10
0 0]
I want to delete [0 0], so the result will be
[1 2
3 4
5 6
0 7
8 0
9 0
0 10]

Accepted Answer

Jonas
Jonas on 30 Jun 2022
Edited: Jonas on 30 Jun 2022
use
rowsToDelete=~any(AB,2);
or
rowsToDelete=all(~AB,2);
AB(rowsToDelete,:)=[];
or
rowsToKeep=any(AB,2);
AB=AB(rowsToKeep,:);

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!