Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

3 次元プロットの作成

この例では、MATLAB® でさまざまな 3 次元プロットを作成する方法を示します。

メッシュ プロット

関数 mesh はワイヤーフレーム メッシュを作成します。既定では、メッシュの色は表面の高さに応じて変化します。

z = peaks(25);

figure
mesh(z)

Figure contains an axes object. The axes object contains an object of type surface.

表面プロット

関数 surf は、3 次元表面プロットの作成に使用されます。

surf(z)

Figure contains an axes object. The axes object contains an object of type surface.

(シェーディング付き) 表面プロット

関数 surfl は、カラーマップベースのライティングをもつ表面プロットを作成します。色がより滑らかに変化するよう、たとえば pink など、線形の強度変化をもつカラーマップを使用します。

surfl(z)
colormap(pink)    % change color map
shading interp    % interpolate colors across lines and faces

Figure contains an axes object. The axes object contains an object of type surface.

等高線図

関数 contour は、定数値の等高線をもつプロットの作成に使用されます。

contour(z,16)
colormap default    % change color map

Figure contains an axes object. The axes object contains an object of type contour.

Quiver プロット

関数 quiver は、2 次元ベクトルを矢印としてプロットします。

x = -2:.2:2; 
y = -1:.2:1;

[xx,yy] = meshgrid(x,y);
zz = xx.*exp(-xx.^2-yy.^2);
[px,py] = gradient(zz,.2,.2);

quiver(x,y,px,py)
xlim([-2.5 2.5])    % set limits of x axis

Figure contains an axes object. The axes object contains an object of type quiver.

3 次元ボリュームのスライス

関数 slice は、容積測定のデータをスライスする平面でのデータを表示します。

x = -2:.2:2;
y = -2:.25:2;
z = -2:.16:2;

[x,y,z] = meshgrid(x,y,z);
v = x.*exp(-x.^2-y.^2-z.^2);

xslice = [-1.2,.8,2];    % location of y-z planes
yslice = 2;              % location of x-z plane
zslice = [-2,0];         % location of x-y planes

slice(x,y,z,v,xslice,yslice,zslice)
xlabel('x')
ylabel('y')
zlabel('z')

Figure contains an axes object. The axes object with xlabel x, ylabel y contains 6 objects of type surface.