How can I generate 3D matrix for different shapes?

2 次查看(过去 30 天)
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.
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 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by