Plot to avoid certain regions in 2D plot
Afficher commentaires plus anciens
I have to plot some random points in 500 x 500 area by avoiding certain area (poly0 and poly1 in the example below) in the 2D-plot.
x = 350.5; y = 350.5; r = 50;
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
poly0 = polyshape(xunit(1:end-1),yunit(1:end-1));
plot(poly0);
hold on;
ploy1 = polyshape([100 100 200 200],[100 200 200 100]); %square
plot(poly1);
hold on
loc = randi([1,500],50, 2);
If I do this, random points overlap the poly0 and poly1 areas. Can anyone help? TIA.
1 commentaire
KSSV
le 2 Nov 2018
x = 350.5; y = 350.5; r = 50;
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
poly0 = polyshape(xunit(1:end-1),yunit(1:end-1));
plot(poly0);
hold on;
poly1 = polyshape([100 100 200 200],[100 200 200 100]); %square
plot(poly1);
hold on
loc = randi([1,500],50, 2);
There was a typo error. What you want to avoid?
Réponse acceptée
Plus de réponses (1)
madhan ravi
le 2 Nov 2018
how about?
plot(loc(loc~=all(poly0.Vertices) & loc~=all(poly1.Vertices)))
1 commentaire
Ananya Malik
le 2 Nov 2018
Modifié(e) : Ananya Malik
le 2 Nov 2018
Catégories
En savoir plus sur Polar Plots dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!