Storing the positions of neighbouring elements that have specific values.
1 view (last 30 days)
Show older comments
Commented: Phillip Smith on 27 Nov 2019
A = zeros(5,5);
I have a matrix of zeros with two 1's in postions (3,4) and (4,1). Starting with the 1 at (3,4) I want to store all the positions of neighbouring elements that are eqaul to 0. I want to do this as my next step is to choose one of the neighbours that equal 0, change that to a 1, and then start the whole process again, starting at any element that equals 1.
dpb on 27 Nov 2019
>> i0=3; j0=4;
You'll have to restrict search to either include only interior initial points or modify to account for location on boundary in computing range vectors.
More Answers (0)
Find more on Matrix Indexing 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!