Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Slice of 3D spherical volume
Replies: 0

 Etienne Posts: 8 Registered: 9/12/11
Slice of 3D spherical volume
Posted: Jan 15, 2013 9:33 AM

Hi there!

I want to find out how to draw a 3D volumetric color-intensity plot of spherical data. I have read a number of posts about this, but none give any working solution.

Basically, I have a 3D matrix V that contains the values of the function f(r,theta,phi) I am interested in. Each of these points in space has spherical coordinates (r,theta,phi). The following code serves as a quick example (where I just used a simple function for V):

r = 0:0.5:120;
thet = 0:1:180;
phi = 0:1:360;

V = zeros(numel(r),numel(thet),numel(phi));

for i=1:numel(r)
rval = r(i);
for j=1:numel(thet)
tval = thet(j);
for k=1:numel(phi)
pval = phi(k);
V(i,j,k) = rval + sin(tval)*cos(pval);
end
end
end

I can easiy use slice to see what the function looks like throughout this volume with

[Rmesh,Tmesh,Pmesh] = meshgrid(thet,r,phi);
sh = slice(Rmesh,Tmesh,Pmesh,V,[100],[80],[150]);
set(sh,'edgecolor','none');

However, I want this volume to appear spherical instead of square. How can I achieve this?

I tried using sph2cart, but the slice function complains that:
X, Y and Z must be matrices produced by MESHGRID. Use TriScatteredInterp instead
of INTERP3 for scattered data.

Any help will be much appreciated!!

Thanks!