Clear Filters
Clear Filters

how can i move the elements of a matrix with 1s and 0s?

1 view (last 30 days)
Hi, so i have a 288x180 matrix with 1s and 0s which was randomly assigned to each of its subpixel. now i need to create a movement of the values in such a way that all the 1s will move towards each other, that is, each value of 0s and 1s will swap continuosly until all the 1s gather in one particular part of the matrix.
P.S: i have taken 1 a pure value indicating presence of a class and 0 as an impure value. Pls help me with the code. i have tried manual assignment of the values but am not getting the required results. Thanks in advance.

Answers (1)

Image Analyst
Image Analyst on 5 May 2016
Edited: Image Analyst on 5 May 2016
I'd treat each 1 as a planet, or a charged particle, and compute the gravitational or electrical force on each particle. Then move the particle in the direction of the net force on that particle. Repeat until all particles are at the same location. Shouldn't be too hard. Give it a try.

Categories

Find more on Gravitation, Cosmology & Astrophysics 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!