How can I change the color of the face of a cube created using the slice command?

3 Ansichten (letzte 30 Tage)
Using this code:
[X,Y,Z] = meshgrid(0:3);
V = X.*exp(-X.^2-Y.^2-Z.^2);
xslice = 0:3;
yslice = 0:3;
zslice = 0:3;
slice(X,Y,Z,V,xslice,yslice,zslice,'nearest'),xlabel('X-Axis'),ylabel('Y-Axis'),zlabel('Z-Axis')
I was able to make the shape I needed but have been unable to change the face colors. Colormap has not allowed me to change faces individually. The closest I got was through the figure editor but I cannot import the changes into my code so that it gives me the colors I want on the faces.

Antworten (1)

Mathieu NOE
Mathieu NOE am 13 Apr. 2021
hello
use handles to modify face colors
here I changes all external faces to black
[X,Y,Z] = meshgrid(0:3);
V = X.*exp(-X.^2-Y.^2-Z.^2);
xslice = 0:3;
yslice = 0:3;
zslice = 0:3;
h = slice(X,Y,Z,V,xslice,yslice,zslice,'nearest'),xlabel('X-Axis'),ylabel('Y-Axis'),zlabel('Z-Axis')
set(h(1),'FaceColor',[0 0 0])
set(h(4),'FaceColor',[0 0 0])
set(h(5),'FaceColor',[0 0 0])
set(h(8),'FaceColor',[0 0 0])
set(h(9),'FaceColor',[0 0 0])
set(h(12),'FaceColor',[0 0 0])

Community Treasure Hunt

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

Start Hunting!

Translated by