Delete 0's in a matrix
1 view (last 30 days)
Show older comments
I have a matrix as following:
A = [0,0;0,0;800,1096;1097,1461;1462,1701]
The amount of rows with 0's can be different depending on the input.
I'm trying to remove all the rows with 0's.
I've tried many different related questions but can't seem to figure it out.
One of the latest solutions I tried is this:
rowsWithZeros = any(A==0,"all");
A = A(~rowsWithZeros,:);
1 Comment
Torsten
on 17 Jan 2023
I'm trying to remove all the rows with 0's.
All rows where at least one element is 0 or all rows where all elements are 0 ?
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!