Effacer les filtres
Effacer les filtres

Finding change in direction

4 vues (au cours des 30 derniers jours)
Tala Dannawi
Tala Dannawi le 22 Avr 2022
Modifié(e) : Tala Dannawi le 28 Avr 2022
I would like to check all neighbor elements for every element in a 600x400 matrix for a change in direction
for i=1:size(gx,1)
for j=1:size(gx,2)
el_1=matrix(i,j) % Give the value of present element having position i,j
el_2=matrix(i,j-1) % Left element
el_3=matrix(i,j+1) % Right element
el_4=matrix(i-1,j) % for upper element
el_5=matrix(i+1,j)%Upper element
el_6=matrix(i-1,j-1) % West-North Diagonal Element....
if el_1*el_2<0
.....
end
end
I thought of checking each element
  1 commentaire
KSSV
KSSV le 22 Avr 2022
REad about gradient.

Connectez-vous pour commenter.

Réponses (1)

Bruno Luong
Bruno Luong le 22 Avr 2022
Your code will crash since indexing will be overflowed.
Just an idea you might do the sign comparison of the entire array
[r,c] = find(matrix(:,1:end-1) .* matrix(:,2:end) < 0);
...
The use r, c to do whatever you want to do next.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by