Counting equal numbers that appear directly next to each other
Ältere Kommentare anzeigen
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 Kommentar
Kirby Fears
am 11 Dez. 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).
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 12 Dez. 2015
0 Stimmen
Kategorien
Mehr zu Error Functions finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!