plot volumetric spherical coordinate data
Afficher commentaires plus anciens
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;
Réponses (1)
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
EDITED: displaying isosurface with patch()
Catégories
En savoir plus sur Scalar Volume Data 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!