필터 지우기
필터 지우기

Select points with boundary

조회 수: 2 (최근 30일)
Yuang
Yuang 2016년 4월 7일
답변: Walter Roberson 2016년 4월 7일
I have a matrix of 2D points like trajectory = [1,1; 1,2; 2,3; 3,4; 4,5; 5,5]
I want to limit it in a square of (0,0), (4,4), (0,4), (4,0).
Is there a way I can delete some rows out of the boundary and get the new trajectory = [1,1; 1,2; 2,3; 3,4]?
I know it is possible to do it in a lot of if statements. Is there a easy way to do that?

채택된 답변

Walter Roberson
Walter Roberson 2016년 4월 7일
traj= [1,1; 1,2; 2,3; 3,4; 4,5; 5,5];
mask = traj(:,1) >= 0 & traj(:,1) <= 4 & traj(:,2) >= 0 & traj(:,2) <= 4;
new_traj = traj(mask,:);

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by