How to solve the error using plot stating color value must be a 3 element vector.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am working with particle swarm optimization.
In the code the following input are used
centroids = 2;
dimensions = 2;
particles = 2;
iterations = 1;
simtime=0.001;
dataset_subset = 2;
wth respect to the above code ,
cluster_colors_vector = rand(particles, 3) is used.
And for plotting the graph the followng command is used:
[ plot(centroid,1,particle),(centroid,2,particle),'o','color',cluster_colors_vector(particle,:)];
Could anyone help me why cluster_colors_vector = rand(particles, 3) is used.why it cant be cluster_colors_vector = rand(particles, 2).If i use the command i am getting stating Error using plot
Color value must be a 3 element vector.
Could anyone please help me on this.
0 Kommentare
Akzeptierte Antwort
KSSV
am 4 Feb. 2019
Note that the color which you speicfy should be a RGB color code......so it should be a 1X3 vector......YOu can check the below:
plot(rand(1,10),'color',rand(1,3))
Randomly the plot will associate some random color.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Particle Swarm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!