How to plot all the points between two lines?

3 次查看(过去 30 天)
So, I have one line that goes from these lat lons :
lat10 = [6.6038,21.841667]; lon10 = [94.4166,62.375000];
plot(x10,y10,'-','color','y');%plotting the line
plot(x10-d,y10,'-','color','y');%plotting a line parallel to the above line
now I'm reading a set of cordinates from an excel sheet :
lat1 = xlsread('101010.xlsx', 'B2:B300');
lon1 = xlsread('101010.xlsx', 'C2:C300');
I want to only plot the points which are within these two lines.If any one point is not in between the lines, I don't want to plot anything. Please help me with how I can do this?

采纳的回答

A. Sawas
A. Sawas 2019-4-6
编辑:A. Sawas 2019-4-6
It seems that you have an area inside a parallelogram defined by four points. Then you can use the inpolygon method as follows:
% find the X of the four points
X = [lat10(1),lat10(2),lat10(1)-d,lat10(2)-d];
Y = [lon10(1),lon10(2),lon10(1),lon10(2)];
% the X and Y of the other points which may or not be inside the parallelogram
lat1 = xlsread('101010.xlsx', 'B2:B300');
lon1 = xlsread('101010.xlsx', 'C2:C300');
[in,on] = inpolygon(lat1,lon1,X,Y);
% (in) contains the indices of the points inside the parallelogram
% (on) contains the indices of the points on the parallelogram
% do some plots
figure
plot(X,Y) % parallelogram
hold on;
plot(lat1(in),lon1(in),'r+') % points inside
plot(lat1(~in),lon1(~in),'bo') % points outside
hold off
  13 个评论
A. Sawas
A. Sawas 2019-4-8
Using the details you provided try this code:
X = [x10,fliplr(x10)-d];
Y = [y10,fliplr(y10)];
[in,on] = inpolygon(x1,y1,X,Y);
% (in) contains the indices of the points inside the parallelogram
% (on) contains the indices of the points on the parallelogram
% do some plots
%plot(X,Y) % parallelogram
plot(x1(in),y1(in),'r+') % points inside
plot(x1(~in),y1(~in),'bo') % points outside

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polar Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by