gregthom <gregthom99@yahoo.com> wrote in message <1c9522f54f3a477cbf96a919a0aaecf4@g3g2000pre.googlegroups.com>...
> ......
> and then my volume is vol = zeros(100,100,100);
> and the xyz spatial info for my volume is
> X = linspace(20,20,100);Z = linspace(20,20,100);,Z = linspace
> (20,20,100);
>
> How can I set the positions occupied by points x,y,z (points in
> sphere) in my vol matrix to = 1; and 0 other wise. If I do that then I
> have a sphere in my 3D volume . Anyone else perhaps with a simpler way
> of doing this ?
> ......
In the question you have posed, Greg, your x, y, z arrays are of no help. To lie inside a sphere, or more generally inside some kind of spherical sector, you need expressions for r, theta, and phi as functions of x, y, and z so that the appropriate inequalities can be tested. Of course in your particular example, all you need is r <= 30, so your test is simply
[x2,y2,z2] = meshgrid(X,Y,Z);
r = sqrt(x2.^2+y2.^2+z2.^2);
vol(r<=30) = 1;
Roger Stafford
