How to plot all the points between two lines?

2 visualizaciones (últimos 30 días)
Rakshit R
Rakshit R el 6 de Abr. de 2019
Comentada: Rakshit R el 8 de Abr. de 2019
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?

Respuesta aceptada

A. Sawas
A. Sawas el 6 de Abr. de 2019
Editada: A. Sawas el 6 de Abr. de 2019
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 comentarios
A. Sawas
A. Sawas el 8 de Abr. de 2019
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
Rakshit R
Rakshit R el 8 de Abr. de 2019
This worked!!
Thanks a lot Sawas. :')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by