plot volumetric spherical coordinate data

4 visualizaciones (últimos 30 días)
Anandu S
Anandu S el 21 de Sept. de 2019
Editada: darova el 22 de Sept. de 2019
How to plot the volumetric spherical coordinate data?
theta=-pi:0.1:pi;
phi=-pi/2:0.1:pi/2;
r=0:10;
[theta phi r]=meshgrid(theta,phi,r);
f= r+theta+phi;

Respuestas (1)

darova
darova el 22 de Sept. de 2019
Editada: darova el 22 de Sept. de 2019
Use isosurface to plot data at specific value
example
clc,clear
% generate some data
theta1 = linspace(-1,1,60)*pi;
phi1 = linspace(-1,1,20)*pi/2;
r1 = 0:10;
[theta, phi, r] = meshgrid(theta1,phi1,r1);
f = r + cos(10*theta);
% boundaries of volume
[X,Y,Z] = sphere(20);
X = r1(end)*X;
Y = r1(end)*Y;
Z = r1(end)*Z;
% create isosurface where f=5
p = patch(isosurface(theta,phi,r,f,5));
% extract spherical data
fc = get(p,'Faces');
vc = get(p,'Vertices');
% convert spherical data to cartesian
[x1,y1,z1] = sph2cart(vc(:,1),vc(:,2),vc(:,3));
vc = [x1 y1 z1];
% plot boundaries
cla
surf(X,Y,Z,'Facecolor','none','edgeColor',[1 1 1]*0.5)
hold on
% plot data f=5 in cartesian
h = patch('Faces',fc,'Vertices',vc);
hold off
set(h,'FaceColor','r','EdgeColor','none');
camlight
lighting gouraud
See my comment HERE of using slice in spherical system coordinates
EDITED: displaying isosurface with patch()

Community Treasure Hunt

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

Start Hunting!

Translated by