Lloydsalgorithm: Color value must be a 3 element numeric vector
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Shawn
el 5 de Jun. de 2014
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 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Voronoi Diagram en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!