How do I find angle of deviation between a set of points and the bounds of a polygon?

3 vues (au cours des 30 derniers jours)
I have a few data being read from an excel sheet. This data is being passed into a function which checks if the data is within the bounds of a polygon (made from the function inpolygon using corner points), and is being plotted on a map. How do I find the angle of deviation between these points and the polygon bounds?
Is it possible for me to fit a line into the data points and check? I have attached an output plot for refrence
Code for reading the data and passing it into the function-
T = readtable('plot1.xlsx',)
checkingcode(T)
Code for checking the data if it is in bound or no-
%defining route bounds---------------
ats = readtable('ATS.xlsx');
lat10=[ats.lat1(1),ats.lat2(1)];
lon10=[ats.lon1(1),ats.lon2(1)];
[x10, y10]= mfwdtran(mstruct,lat10,lon10);
X = [x10,fliplr(x10)];
Y = [y10,fliplr(y10)-d];
%defining route bounds---------------
%checking if data is within the bound--------
[journeys.x, journeys.y] = mfwdtran(mstruct, journeys.latitude, journeys.longitude); %transform the flights latitude and longitude
in = inpolygon(journeys.x, journeys.y, X, Y);
[groupid, flights] = findgroups(journeys.flight);%assign unique id to each flight and apply to rows of the table
inratio = splitapply(@(in)nnz(in)/numel(in), in, groupid); %ratio of points in polygon to points in flight
selectedflights = flights(inratio >= 0.9); %for flights that have 70% of their journey in the polygon
selectedjourneys = journeys(ismember(journeys.flight, selectedflights), :); %portion of the table with only the selected flights.
%checking if data is within the bound--------
%plotting------
plot(x10,y10,'-','color','m');%plotting ats bound 1
hold on;
plot(x10,y10-d,'-','color','m'); %plotting parallel bound of ats bound 1
[sx, sy] = mfwdtran(mstruct, selectedjourneys.latitude, selectedjourneys.longitude);
scatter(sx,sy,[],color, 'Marker','+') %plotting all flights in between the ats route
%plotting------
untitled.jpg

Réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by