Effacer les filtres
Effacer les filtres

How to solve the error using plot stating color value must be a 3 element vector.

4 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

KSSV
KSSV le 4 Fév 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.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by