Given a matrix a, return a matrix b in which all the zeros have "bubbled" to the top. That is, any zeros in a given column should be moved to the top. The order of the remaining nonzero numbers in the column should be preserved.
Example 1
Input a = [ 1 2 3
0 4 5
6 0 0 ] Output b is [ 0 0 0
1 2 3
6 4 5 ]Example 2
Input a = [ 1 0 5 0 6 0 7 ]' Output b is [ 0 0 0 1 5 6 7 ]'
Example 3
Input a = [ 1 0
1 1 ]
Output b is [ 1 0
1 1 ]
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers1323
Suggested Problems
-
1621 Solvers
-
Longest run of consecutive numbers
6436 Solvers
-
Generate N equally spaced intervals between -L and L
942 Solvers
-
Create an n-by-n null matrix and fill with ones certain positions
712 Solvers
-
1110 Solvers
More from this Author54
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
love this one
28 attempts later, we finally made it
nice question!
good problem
good analogy