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

Réponses (2)

Walter Roberson
Walter Roberson le 8 Avr 2011

0 votes

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 le 12 Fév 2019

0 votes

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

Catégories

En savoir plus sur Polar Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by