How to solve the error using plot stating color value must be a 3 element vector.
4 ビュー (過去 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.
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Particle Swarm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!