Filter löschen
Filter löschen

'Exceeded the maximum number (8) of light sources' When trying to plot two shrinking spheres on the same figure

31 Ansichten (letzte 30 Tage)
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

Antworten (1)

xiaodong lu
xiaodong lu am 22 Mär. 2024
You create too many figures and lights, try
>>gcf
and
>>delete(gcf)
then, you can use camlight() without warning again

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by