필터 지우기
필터 지우기

Distance from x,y coordinates [Beginner]

조회 수: 1 (최근 30일)
Alex castilla
Alex castilla 2018년 3월 23일
Hello everybody, I have a small question:
I have two matrices: A(2099x2) and B(9x4).
Matrix A = trajectory (x,y coordinates)
Matrix B = X,Y coordinates of 9 targets (black square dots), the width=0.20 and the height= 0.20.
I would like to know if the trajectory (blue line) passes through the green area (green square) around the black square.
I'm working on a code but It doesn’t seem to work, any suggestions?:
reach_target= zeros(9,1);
for i = 1:9
if A(1,:) > (B(i,1) - (w/2)) & A(1,:) < (B(i,1) + (w/2))
if A(:,2) > (B(i,2) - (h/2)) & A(:,2) < (B(i,2) + (h/2))
reach_target(i)=1;
else
reach_target(i)=0;
end
end
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Coordinate Transformations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by