Spherical 3D array

3 次查看(过去 30 天)
Francesca
Francesca 2011-4-8
Hi,
I am very new to matlab and I hope someone can help me. I am desperately trying to generate a 3D array in the shape of a sphere (instead of a 3D cuboid). I also want to set the value of each element of the 3D spherical array to 99 and plot it. Does anyone know how I should do it? I have tried with a cuboid as shown below:
T=12; N=24; row=1; for z=(((2*N-T)/4)+1): ((((2*N+T)/4))) for y=(((2*N-T)/4)+1): ((((2*N+T)/4))) for x=(((N-T)/2)+1): (((N+T)/2))
array(x,y,z) = 99;
array(row,1)=y;array(row,2)=x;array(row,3)=z;
row=row+1;
end
end
end
plot3(array(:,2), array(:,3), array(:,1),'r*', 'Color', [0, 0, 0])
I would very much appreciate if someone could help. thanks

回答(2 个)

Walter Roberson
Walter Roberson 2011-4-8
MATLAB is not able to create numeric arrays in the shape of a sphere, only in N-dimensional cuboids.
You can create a cube and fill in the (discrete approximation to) a sphere within it, but then you run into difficulties in plotting the result. 3 spacial dimensions plus one value per location gives you 4 dimensional data, and there is no plotting routine for 4 dimensional data.
If I recall correctly there is a MATLAB File Exchange contribution that does some voxelization drawing.

jerry brackett
jerry brackett 2019-2-12
int a[10] [3] [5] its base address is 89. what is the address of element a[7] [2] [4] ?

类别

Help CenterFile Exchange 中查找有关 Polar Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by