Lloydsalgorithm: Color value must be a 3 element numeric vector
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I ran the Lloydsalgorithm function for a shapefile of one of Ohio's congressional districts. It accepts the file and iteratively draws a Voronoi diagram with the number of robots that I give it (n robots create n regions, or cells). The original code, without my additions, can be found at http://www.mathworks.com/matlabcentral/fileexchange/41507-lloyds-algorithm/content/lloydsAlgorithm.m
My problem is in this part of the code, where I am coloring the cells. The error message deals with the bolded line; it says, "Error using plot; Color value must be a 3 element numeric vector". I'm not sure what this is telling me. Any suggestions are welcome and greatly appreciated; if you would like to see the entire file, you can find it here: https://drive.google.com/?tab=mo&authuser=0#folders/0B3fa1Bco9n2EcV9jbHc3RENfLWM
%%%%VISUALIZATION
if showPlot
verCellHandle = zeros(1,n);
cellColors = cool(n);
for i = 1:numel(Px) % color according to
verCellHandle(i) = patch(Px(i),Py(i),cellColors(i,:)); % use color i -- no robot assigned yet
hold on
end
pathHandle = zeros(1,n);
%numHandle = zeros(n,1);
*for i = 1:numel(Px) % color according to
pathHandle(i) = plot(Px(i),Py(i),'-','color',cellColors(:,i)*.8);*
% numHandle(i) = text(Px(i),Py(i),num2str(i));
end
goalHandle = plot(Px,Py,'+','linewidth',2);
currHandle = plot(Px,Py,'o','linewidth',2);
titleHandle = title(['o = Robots, + = Goals, Iteration ', num2str(0)]);
end
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Voronoi Diagram dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!