Coordinates/values around number in array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello
Say I want to choose a value in an array and I want to find the value of the elements that surround them. Say the number i pick is 2 in the array below. I know I could find all the 2's and look north south east and west of each 2 in the array. I just wanted to know if there was a more elegent way
thank you
Andrew
3 1 1 1 1 %let say I pick "2", so the elements are 1,3,1,1,1,1,1,4
3 3 1 1 1
3 1 2 2 1
1 3 2 7 1
1 1 2 4 1
0 comentarios
Respuestas (1)
KSSV
el 8 de Mayo de 2022
If (i,j) is the index of number 2; then the nearest elements to it will be (i-1,j),(i+1,j),(i,j+1),(i,j-1),(i+1,j-1),(i+1,j+1),(i-1,j-1),(i-1,j+1).
Also have a look on knnsearch, rangesearch.
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!