How to attribute intersection points between poly and lineseg to poly

I'm trying to plot an animal's trajectory from a set of coordinates as a line segment. I want to see how many coordinates are plotted inside a circular zone vs outside. I think that coordinates which intersect with the circle are being counted as both inside and outside, but I would like them to be strictly counted as inside. This is what I have so far:
[in,out] = intersect(circle_poly,trajectory);
plot(circle_poly)
hold on
plot(in(:,1),in(:,2),'b',out(:,1),out(:,2),'r')
legend('Polygon','Inside','Outside','Location','NorthWest')
num_frames_in = numel([in]) %count num elements/frames in polygon
num_frames_out = numel([out]) %count num element/frames outside polygon
total_frames = num_frames_in + num_frames_out
Any help would be really appreciated since I'm new to Matlab!

답변 (2개)

KSSV
KSSV 2022년 2월 16일

0 개 추천

You can use inpolygon. This will show your points lying on and inside the circle.
Matt J
Matt J 2022년 2월 16일
num_frames_in = size(in,1) %count num elements/frames in polygon
num_frames_out = size(out,1) %count num element/frames outside polygon

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

제품

질문:

2022년 2월 16일

댓글:

2022년 2월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by