你可以参考下这个例子:
clc; clear;
n = 51;
x = linspace(-5, 5, n);
y = x;
z = x;
[X, Y, Z] = meshgrid(x, y, z);
v = exp(-(X.^2+Y.^2+Z.^2)/1e3);
figure('position', [100, 200, 700, 600]);
colormap(jet);
s1 = slice(X, Y, Z, v, [], [], z([20, 30]));
set(s1, 'FaceColor', 'interp', 'EdgeColor', 'none');
cbar = colorbar();
ylabel(cbar, 'data');
xlabel('x'); ylabel('y'); zlabel('z');
set(gca, 'fontsize', 16);
|