How can the plot be divided into 2 using the graph line?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone,
I have a graph that I obtained with the help of the RRT algorithm.
In addition, I have an array of points that are on the plot as you can see.
I want to write a function \ use a classification algorithm (or any other machine learning algorithm) to divide the points into 2 using the graph (points on the right side of the graph and points on the left side)
How can this be done? I tried several options but failed.. :/
I would be very happy to help! :)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1524086/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1524091/image.png)
0 Commenti
Risposta accettata
Matt J
il 2 Nov 2023
Modificato: Matt J
il 2 Nov 2023
Perhaps something like the following:
load roadPoints
[X,Y]=ndgrid(0:2.5:100);
p1=polyshape([roadPoints;min(roadPoints(:,1)), max(roadPoints(:,2))],'Simplify',true);
p2=polyshape([roadPoints;max(roadPoints(:,1)), min(roadPoints(:,2))],'Simplify',true);
class1=isinterior(p1,X(:),Y(:));
class2=isinterior(p2,X(:),Y(:));
noclass=~(class1|class2);
hold on
scatter(X(class1), Y(class1),'g','filled','MarkerEdgeColor','none');
scatter(X(class2), Y(class2),'c','filled','MarkerEdgeColor','none');
scatter(X(noclass),Y(noclass),'MarkerFaceColor',[0.5,0.5,0.5],'MarkerEdgeColor','none')
plot(roadPoints(:,1), roadPoints(:,2),'r','LineWidth',5);
legend('Class 1', 'Class 2','UnClassified','Location','NorthOutside')
hold off
5 Commenti
Più risposte (2)
Image Analyst
il 29 Ott 2023
It looks like all the points on the right have a y value greater than about 6, so just do
rightIndexes = (y >= 6);
xRight = x(rightIndexes);
yRight = y(rightIndexes);
xLeft = x(~rightIndexes);
yLeft = y(~rightIndexes);
3 Commenti
Dyuman Joshi
il 2 Nov 2023
Is the route completely random or can a relation/observation be identified?
And you have not defined what is the criteria/logic to be used for dividing points to the left and right side.
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!