Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

could anyone help me to solve the issue.

1 vue (au cours des 30 derniers jours)
jaah navi
jaah navi le 8 Fév 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
I am getting the figure when my code executes:
With respect to the figure the 12 black small circle represents the number of users and 5 colourful big circle represents the particles.
using my code i measured the distance of each and every particle with respect to 12 users.
based upon the distance measurements the color of the small circle needs to be changed .
for example,if particle 1 is chosen to be the best then the result from the command window:
particle 1 (dimensions) = 1.4625 2.2959
distance of particle 1 with respect to 12 users :
2.8405
2.7748
1.8211
2.7829
1.8504
2.3174
0.2868
0.8485
2.1030
0.3243
0.2199
0.7376
Now the color of the 12 users needs to be changed according to this distance measurement.
the first minimum distance user and first maximum distance users needs to be in same color
the second minimum distance user and secondmaximum distance users needs to be in another same color.
the third minimum distance user and third maximum distance users needs to be in another same color and goes on.
Could anyone please help me on this.
  1 commentaire
Guillaume
Guillaume le 8 Fév 2019
Modifié(e) : Guillaume le 8 Fév 2019
It would be helpful to know:
  • how the particles and users are stored
  • how the distances are stored
  • how the plot was generated (in particular, have you got handles to the graphics objects?)
  • the maximum number of colours you expect to need (are the 7 default colors of ColorOrder enough?)

Réponses (1)

jaah navi
jaah navi le 8 Fév 2019
clear all;
clc;
user=12;
particles=5;
dimensions=2;
for t = 1:length(user)
d = zeros(user(t),1) ;
Xmax=1;
Ymax=1;
radius=2;
xsd=ones(1,user(t))*Xmax;
ysd=ones(1,user(t))*Ymax;
rrx=radius*sqrt(rand(1,user(t)));
thetarx=2*pi*rand(1,user(t));
xrx=xsd+rrx.*cos(thetarx);
yrx=ysd+rrx.*sin(thetarx) ;
th = 0:pi/100:2*pi;
xunit = radius * cos(th) + Xmax;
yunit = radius * sin(th) + Ymax;
d = sqrt((xsd.'-xrx.').^2+(ysd.'-yrx.').^2) ;
figure
plot(xunit, yunit);
hold on
plot(yrx,xrx,'ko')
hold on
end
swarm_pos = rand(1,dimensions,particles);
A=[xrx.' yrx.']
dataset_size=size(A);
distances=zeros(dataset_size(1),1,particles);
for particle=1:particles
distance=zeros(dataset_size(1),1);
for data_vector=1:dataset_size(1);
distance(data_vector,1)=norm(swarm_pos(1,:,particle)-A(data_vector,:));
end
distances(:,1,particle)=distance
end
pc=[];
cluster_colors_vector = rand(particles, 3);
hold on;
for particle=1:particles
pc = [pc plot(swarm_pos(1,1,particle),swarm_pos(1,2,particle),'o','color',cluster_colors_vector(particle,:))];
end
set(pc,{'MarkerSize'},{12});
hold off;

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by