Effacer les filtres
Effacer les filtres

Request for matlab code regarding divsion of sub grids in a scatter plot

1 vue (au cours des 30 derniers jours)
Palanchu Jyothirmai
Palanchu Jyothirmai le 21 Nov 2019
I have designed a scatter plot by using below code:
clear all, close all, clc;
xm =100;
ym = 100;
sink.x =0.5*xm;
sink.y =0.5*ym;
n =200;
p = 0.05;
m = 0.1;
rmax = 10;
figure;
for i = 1:1:n
S(i).xd = rand(1,1)*xm;
XR(i)= S(i).xd;
S(i).yd = rand(1,1)*ym;
YR(i)= S(i).yd;
S(i).G = 0;
S(i).type = 'N';
temp_rnd0 = i;
if(temp_rnd0>=m*n+1)
plot(S(i).xd, S(i).yd,'o');
hold on;
end
end
S(n+1).xd = sink.x;
S(n+1).yd = sink.y;
plot(S(n+1).xd,S(n+1).yd,'x');
for r = 0:1:rmax;
if(mod(r, round(1/p)) == 0)
for i= 1:1:n
S(i).G = 0;
S(i).cl = 0;
end
end
cluster = 1;
for i =1:1:n
temp_rand = rand;
if ((S(i).G)<=0)
if(temp_rand<= (p/(1-p*mod(r,round(1/p)))))
S(i).type = 'C';
S(i).G = round(1/p)-1;
C(cluster).xd = S(i).xd;
C(cluster).yd = S(i).yd;
plot(S(i).xd,S(i).yd,'k*');
end
end
end
end
NrGrid = 2; % Number Of Grids
x = linspace(0, 100, NrGrid+1);
[X,Y] = meshgrid(x);
figure(1)
plot(X,Y)
hold on
plot(Y,X)
hold off
I have divided that scatter plot into 4 zones using 'NrGrid'. Now depending on density of points in each zone i have to divide it into subgrids i.e; if density is high then divide it to 4 zones, if density is medium divide it to 2 zones and if density is less no division. So, Can anyone please help me in implementing code for division of this grid into subgrids?? I have attached my output to the code till now below.
jyo.PNG
  2 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 21 Nov 2019
Modifié(e) : KALYAN ACHARJYA le 21 Nov 2019
How to get the density? Is there any specific marker or all?
Is there any specific value of range, whether it may be high or medium?
Palanchu Jyothirmai
Palanchu Jyothirmai le 21 Nov 2019
Thankyou so much for your kind and speed reply @KALYAN ACHARJYA sir. First I have to get density of points in (XR(i),YR(i)) <= (50,50) i.e; one zone . Similarly in all zones, after that depending on density in each zone i have to create sub grids in each zone. I.e; I have given total of points 200(there is no distinguistion between 'o' & 'k*' all are points only). So now, if density is >25% of total points then it is mentioned as high and then we should divide zone into 4 subzones. Similarly, if density is <25% & >15% of total points then it is mentioned as medium and then we should divide zone into 2 subzones and if density is <15% of total points then it is mentioned as low and then there is no division of subzones. This is the procedure sir. I am even attaching an algorithm of code below sir.
Define N global variable
Get N (total number of nodes in the network)
Get border_lines (Left_line, Right_line, Top_line, Bottom_line)
Divide_Network_to_Four_Zones (Zl, Zr,Zu, Zw)
for all zones i do
Nz[i] <- Get
Number_of_nodes_per_zone[i]
dz[i]^ Nz/N
if dz[i]>0.25 then
density_factor[i] <- High
else if 0.25 > density_factor[i] > 0.15
then
density_factor[i] <- Midium
else if 0.15 > density_factor[i]
density_factor[i] <- Low
end if
Broadcast density_factor[i]
if density_factor[i] <- High then
Devide_Zone_to_Four_Clusters[i]
for all Clusters j do
for all nodes k do
Node_Membership[i] [j] [k]
if No_Membership [j ] [i] [k] then
Delete_Cluster
end if
end for
end for
else if density_factor[i] <- Medium
then
Devide_Zone_to_Two_Clusters[i]
for all Clusters j do
for all nodes k do
Node_Membership[i] [j] [k]
if No_Membership[j][i][k] then
Delete_Cluster
end if
end for
end for
else if density_factor[i] <- Low then
Devide_Zone_to_One_Clusters[i]
for all Clusters j do
for all nodes k do
Node_Membership[j] [i] [k]
if No_Membership [j ] [i] [k] then
Delete_Cluster
end if
end for
end for
end if
end for

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by