필터 지우기
필터 지우기

Finding change in direction

조회 수: 2 (최근 30일)
Tala Dannawi
Tala Dannawi 2022년 4월 22일
편집: Tala Dannawi 2022년 4월 28일
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
KSSV
KSSV 2022년 4월 22일
REad about gradient.

댓글을 달려면 로그인하십시오.

답변 (1개)

Bruno Luong
Bruno Luong 2022년 4월 22일
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.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by