| Contents | Index |
light('PropertyName',propertyvalue,...)
handle = light(...)
For a list of properties, see Light Properties.
light creates a light object in the current axes. Lights affect only patch and surface objects.
light('PropertyName',propertyvalue,...) creates a light object using the specified values for the named properties. For a description of the properties, see Light Properties. The MATLAB software parents the light to the current axes unless you specify another axes with the Parent property.
handle = light(...) returns the handle of the light object created.
You cannot see a light object per se, but you can see the effects of the light source on patch and surface objects. You can also specify an axes-wide ambient light color that illuminates these objects. However, ambient light is visible only when at least one light object is present and visible in the axes.
You can specify properties as property name/property value pairs, structure arrays, and cell arrays (see set and get for examples of how to specify these data types).
See also the patch and surface AmbientStrength, DiffuseStrength, SpecularStrength, SpecularExponent, SpecularColorReflectance, and VertexNormals properties. Also see the lighting and material commands.
Light the peaks surface plot with a light source located at infinity and oriented along the direction defined by the vector [1 0 0], that is, along the x-axis.
h = surf(peaks);
set(h,'FaceLighting','phong','FaceColor','interp',...
'AmbientStrength',0.5)
light('Position',[1 0 0],'Style','infinite');
You can set default light properties on the axes, figure, and root object levels:
set(0,'DefaultLightProperty',PropertyValue...) set(gcf,'DefaultLightProperty',PropertyValue...) set(gca,'DefaultLightProperty',PropertyValue...)
where Property is the name of the light property and PropertyValue is the value you are specifying. Use set and get to access light properties.
For more information about lighting, see Lighting as a Visualization Tool in the MATLAB Graphics User Guide.
Light Properties | lighting | material | patch | surface

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |