plot volumetric spherical coordinate data

조회 수: 14 (최근 30일)
Anandu S
Anandu S 2019년 9월 21일
편집: darova 2019년 9월 22일
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;

답변 (1개)

darova
darova 2019년 9월 22일
편집: darova 2019년 9월 22일
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()

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by