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

5 次查看(过去 30 天)
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.

采纳的回答

KSSV
KSSV 2019-2-4
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 个)

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by