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!

Antworten (2)

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

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 16 Feb. 2022

Kommentiert:

am 18 Feb. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by