Problem 2442. Magnet and Iron
(Inspired from Problem 112: Remove the air bubbles)
Iron (atomic number = 26) is strongly attracted by magnet. The input matrix contains some iron elements (26). I placed two strong magnetic bars above the top row and below the bottom row. What will be state of the matrix after the iron elements have moved due to attraction? Elements equidistant from both magnets will not change their positions.
Example:
Input =
1 26 3 26 26 26 0 0 -12 NaN 26 26
Output = 26 26 1 26 3 26 0 0 -12 NaN 26 26
Solution Stats
Problem Comments
-
2 Comments
In test 1 why the iron in x(4,1) did not moved to the top !?
x(4,1) is equidistant to both upper and lower magnet, that's why...
Solution Comments
Show commentsProblem Recent Solvers119
Suggested Problems
-
Removing rows from a matrix is easy - but what about inserting rows?
229 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
767 Solvers
-
667 Solvers
-
175 Solvers
-
10031 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!