Intersecting lines from coordinates and fixed lines

조회 수: 2 (최근 30일)
Emmanouil Barmpounakis
Emmanouil Barmpounakis 2015년 4월 27일
댓글: Emmanouil Barmpounakis 2015년 4월 27일
How can I find the intersecting points between the line that is created from a set of coordinates and a fixed line? I am trying to use the Curve Intersections function.
Specifically, I have a set of coordinates with x: (NAN NAN NAN x1 x2 x3 x4 x5... xN-1 xN NAN NAN NAN) and y:(NAN NAN NAN y1 y2 y3 y4 y5...yN-1 yN NAN NAN NAN). I want to find whether the line created from these connected corrdinates is intersecting a line with specific start and end point.
x1=val(:,2);
y1=val(:,3);
x2=[-226.586 , -238.954];
y2=[112.566 , 49.459];
plot(x1,y1,x2,y2)
P = InterX([x1;y1],[x2;y2]);
plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro'
And the result I get is:
Error using .*
Matrix dimensions must agree.
Error in InterX (line 60)
S1 = dx1.*y1(1:end-1) - dy1.*x1(1:end-1);
while the plot work just fine! Then, I want to a counter to increase by one IF there is an intersection point between these two lines.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 4월 27일
x1=val(:,2);
y1=val(:,3);
x2=[-226.586 , -238.954];
y2=[112.566 , 49.459];
plot(x1,y1,x2,y2)
P = InterX([x1.';y1.'],[x2;y2]);
plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by