How can I change the color gradient when using interpolated shading in MATLAB 7.0.4 (R14SP2)?

6 Ansichten (letzte 30 Tage)
The following code creates a sphere and colors it using interpolated shading:
sphere(30)
axis equal
shading interp
I want to change the rate of shading within the sphere. For example,to make most of the sphere grey while coloring the rest of the sphere using interpolated shading.

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 27 Jun. 2009
The ability to change the interpolation method for the shading rate or color gradient is not available in MATLAB 7.0.4.
To work around this issue, manually adjust the extent to which a figure is shaded with a certain color by changing the colormap of the figure. For example, the following code will first color a sphere using the default colormap. It will then modify the figures's colormap to achieve a different color gradient.
sphere(30)
axis equal
colormap bone
a=colormap;
a(1:30,1:3)=.5;
colormap(a)
This displays a sphere with most of the sphere shaded from grey to white instead of from black to white. By appropriately changing the values of the colormap matrix (each element takes values between 0 and 1), it is possible to implement a desired shading scheme. You can also influence color gradients by specifying lighting characteristics, such as light position and the ratio of ambient and diffuse components.

Weitere Antworten (0)

Produkte


Version

R14SP2

Community Treasure Hunt

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

Start Hunting!

Translated by