Lloydsalgorithm: Color value must be a 3 element numeric vector
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Voronoi Diagram 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!