Lloydsalgorithm: Color value must be a 3 element numeric vector

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

采纳的回答

José-Luis
José-Luis 2014-6-5
编辑:José-Luis 2014-6-5
pathHandle(i) = plot(Px(i),Py(i),'-','color',cellColors(:,i)*.8);*
Should be
pathHandle(i) = plot(Px(i),Py(i),'-','color',cellColors(i,:)*.8);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Voronoi Diagram 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by