Lloydsalgorithm: Color value must be a 3 element numeric vector
조회 수: 4 (최근 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
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Voronoi Diagram에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!