'Exceeded the maximum number (8) of light sources' When trying to plot two shrinking spheres on the same figure
17 次查看(过去 30 天)
显示 更早的评论
I have written some code for a project which works out the radius of droplets of water as a function of time (r1,r2) depending on the input variables (size,temp,velocity) and I want to plot two droplets on the same figure shrinking to compare the two. The code works fine with one droplet but when I try to plot two spheres at the same time I get the warning Warning: 'Error updating Light Exceeded the maximum number (8) of light sources' and the figure stops updating. Here is the plotting part of the code:
for i = 1:size(r1,2)
[X,Y,Z] = sphere ;
if selection1(3)<5
surf(X*r1(i),Y*r1(i),Z*r1(i), 'FaceColor', [0 0 0.07*selection1(3)])
elseif selection1(3)<10
surf(X*r1(i),Y*r1(i),Z*r1(i), 'FaceColor', [0.15*selection1(3) 0.15*selection1(3) 0])
else
surf(X*r1(i),Y*r1(i),Z*r1(i), 'FaceColor', [0.07*selection1(3) 0 0])
end
hold on
if selection2(3)<5
surf(X*r2(i)+0.001,Y*r2(i),Z*r2(i), 'FaceColor', [0 0 0.07*selection2(3)])
elseif selection1(3)<10
surf(X*r2(i)+0.001,Y*r2(i),Z*r2(i), 'FaceColor', [0.15*selection2(3) 0.15*selection2(3) 0])
else
surf(X*r2(i)+0.001,Y*r2(i),Z*r2(i), 'FaceColor', [0.07*selection2(3) 0 0])
end
light('Position',[-1 -1 -1],'Style','local')
drawnow
axis([-0.0005 0.002 -0.001 0.001 -0.001 0.001])
pause(0.1)
end
The if else statements are just to set the colour of the sphere depending on the temperature.
Thank you
0 个评论
回答(1 个)
xiaodong lu
2024-3-22
You create too many figures and lights, try
>>gcf
and
>>delete(gcf)
then, you can use camlight() without warning again
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!