How to find the points in specific areas of the graph
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When i plug this into matlab i am trying to get the amount of dots per area in the graph produced. (ar1...ar4). I tried to find the area above and below sections of the lines that run through the graph but I keep messing it up. What can I change to correct this issue?
n =
for k = 1:20
x = 8 * rand(1,n);
y = 8 * rand(1,n);
hold off
scatter (x,y)
hold on
u = [0:0.01:8];
for i = 1: length(u)
v1(i) = u(i);
if u(i) <= 8
v2(i) = 8-u(i);
u(i) - u(i);
end
end
plot(u,v1,u,v2)
ar1 = 0;
ar2 = 0;
ar3 = 0;
ar4 = 0;
for i = 1:length(x)
if y(i) > x(i)
ar1 = ar1 +1;
else
if y(i)< 8-x(i)
ar2 = ar2 +1;
else
ar3= ar3+1;
end
end
end
end
0 commentaires
Réponses (1)
KSSV
le 11 Déc 2018
YOu have the lines/ boundaries of your required area in hand. Use inpolygon to get the points/ dots that lie inside the give area. Read about inpolygon.
0 commentaires
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms 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!