How to solve the error using plot stating color value must be a 3 element vector.
5 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
KSSV
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Particle Swarm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!