How can I generate 3D matrix for different shapes?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I am trying to generate 3D matrices for different shapes as given in below figure like cylinders, cylinder with holes or donut shape etc.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167644/image.png)
I tried to generate cube with some inner cubes in 3D using following codes as below.
% numbers are arbitrary
cube=zeros(11,11,11);
cube(3:9,3:9,3:9)=5; % Create a cube inside the region
% Boring: faces of the cube are a different color.
cube(3:9,3:9,3)=2;
cube(3:9,3:9,9)=2;
cube(3:9,3,3:9)=2;
cube(3:9,9,3:9)=2;
cube(3,3:9,3:9)=2;
cube(9,3:9,3:9)=2;
vold3d('Cdata',cube,'alpha',cube/5)
and I got results as below
</matlabcentral/answers/uploaded_files/98386/shapes1.png> Even I could generate these shapes in cartesisan co-ordinate system. But I couldn't generate as matrix.
How can I generate 3D matrix for above mentioned shapes. This matrix can be 128x128x128 or512x512x512 size. Can anyone help
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!