Counting equal numbers that appear directly next to each other
Mostrar comentarios más antiguos
I'm trying to achieve this for a while now but I can't figure out to do this in an easy and understandable way.. Imagine a 2D-matrix(e.g 30x30) containg ones and zeros. there is an inital position on one of the zeros in the matrix, this zero then becomes a 2. Now, if the 2 has any 0 above/below or left/right, make these zeros 3. then do the same for 3 and so on untill it reaches the boundary of the matrix(In this case the ouput is the smallest value it reaches the boundary with) or it cannot reach the boundary of the matrix(In that case the output =0)
This is essentially a shortest path finder for a labyrinth in a matrix of zeros and ones. where zeros represent an open path and ones the walls.
1 comentario
Kirby Fears
el 11 de Dic. de 2015
Try making a function that performs the first step (given a matrix with 1's, 0's, and a single 2 not on the boundary) and returns the matrix with 3's added where possible.
Then try adding recursion inside of your function (at the end).
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 12 de Dic. de 2015
0 votos
Categorías
Más información sobre Error Functions en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!