필터 지우기
필터 지우기

Writing Code for Function

조회 수: 1 (최근 30일)
Lauren Kinchla
Lauren Kinchla 2019년 11월 13일
답변: David Hill 2019년 11월 13일
Write a function named insideBounds which receives a 1-by-2 vector representing the x-y coordinates of a point in [x,y] form and a 4-by-2 matrix representing four points in [x,y] form. The four points represent the vertices of a rectangle in clockwise order around the center of the rectangle. The function must return a logical value (1 or 0) indicating if the point is inside the rectangle specified by the matrix passed as input. The function should have the name and parameters of
insideBounds(myPoint, rectangleVertices)
For example if the function entered is insideBounds([1,1],[0,0;0,2;4,2;4,0]) then the function should return 1

답변 (1개)

David Hill
David Hill 2019년 11월 13일
function yn=insideBounds(P,r)
pgon=polyshape(r(:,1),r(:,2));
yn=isinterior(pgon,P);
end

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by