Finding index between two parallel lines
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have bathymetry data (an intuition is attached here) which is stored in a regular 10m-resolution grid with the following limits:
- In the x-axis: xmin:10:xmax. This contains 3039 columns
- In the y-axis: ymin:10:ymax. This forms 1195 rows
- The depth is Z matrix whose size is equal to 1195x 3039;
And I have 2 parallel lines crossing this bathymetry with the following information:
- Line 1 is defined as points (x1,y1) and (x2,y2)
- Line 2 is defined as points (x3,y3) and (x4,y4)
My task is to find indices between these two lines. Could you please help to solve this?
Many thanks
T
댓글 수: 2
Star Strider
2019년 3월 10일
‘My task is to find indices between these two lines.’
‘Index’ means different things in different contexts (e.g. matrix, book, etc.). How do you define it here?
채택된 답변
darova
2019년 3월 10일
You can use inpolygon
clc, clear
xmin = 50;
xmax = 551;
ymin = -35;
ymax = -800;
y1 = ymax + 150;
y4 = ymin - 150;
k_up = (y1 - ymin)/(xmax-xmin);
k_down = (ymax - y4)/(xmax-xmin);
cla, hold on
for x = xmin:10:xmax
y_start = ceil(y1 - x*k_up);
y_end = floor(ymax - x*k_down);
for y = y_start:-10:y_end
plot(x,y,'.r')
end
end
hold off
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!