Clear Filters
Clear Filters

Why can't I generate a sphere with a material?

1 view (last 30 days)
Hi!
The following is my code. I intended to generate a sphere with a material shiny but I could't make it. Can anyone to tell me what lines I need to put in or modify?
Thank you.
[X,Y,Z]= sphere;
x2 = X.*50;
y2 = Y.*50;
z2 = Z.*50;
h = surf(x2,y2,z2);
material shiny;
axis vis3d off
set(h,'LineWidth',1.5);
This is what I want. Shiny. But I can't make it.
sphere(50); shading flat;
light('Position',[1 3 2]);
light('Position',[-3 -1 3]);
material shiny;
axis vis3d off;

Accepted Answer

DGM
DGM on 30 Jan 2022
Edited: DGM on 30 Jan 2022
Set up the lights.
[X,Y,Z]= sphere(20);
x2 = X.*50;
y2 = Y.*50;
z2 = Z.*50;
h = surf(x2,y2,z2);
light('Position',[1 3 2]);
light('Position',[-3 -1 3]);
material shiny;
axis vis3d off
FWIW, the default material is pretty shiny already, but you can always tweak the constants individually if you want.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!