clear, clc, close all
x=[7.5 7.5 7.5 7.5 10 10 10 10 10 10 10 10 10 12.5 12.5 12.5 12.5];
y=[50 40 60 50 50 50 50 50 40 40 60 60 50 50 40 60 50];
z=[34 36 36 38 36 36 36 36 38 34 36 34 36 34 36 36 38];
D=[23.237 23.856 24.998 28.923 27.897 26.346 26.146 26.236 26.470 19.581 24.645 20.186 26.256 21.496 20.444 24.516 23.350];
over the range 7.5≤ x ≤ 12.5, 40 ≤y ≤50, 34 ≤ z ≤38:
D=(-1482.66715-1.16168.*x+4.72252.*y+76.9875.*z+0.0293.*x.*y+0.0068.*x.*z-0.06075.*y.*z-0.045336.*x.^2-0.028393.*y.^2-1.01635.*z.^2);
[x,y,z] = meshgrid(7:.2:13,35:.2:65,32:.2:40);
v = x.*exp(-x.^2-y.^2-z.^2);
xslice = [8,10,12];
yslice = [40,50,60];
zslice = [34,36,38];
slice(x,y,z,D,xslice,yslice,zslice)
colormap hsvfigure(1)
scatter3(x(:), y(:), z(:), 2, D(:), 'filled')
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
xlabel('X')
ylabel('Y')
zlabel('Z')
colorbar
[x,y,z] = meshgrid(x,y,z);
v = x.*exp(-x.^2-y.^2-z.^2);
xslice = [9,11];
yslice = [40,60];
zslice = [34,38];
slice(x,y,z,D,xslice,yslice,zslice)
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
xlabel('X')
ylabel('Y')
zlabel('Z')
colormap hsv
colorbar
% form the axes
x = 0:0.5:10; % first dimension independent variable
y = 0:0.5:10; % second dimension independent variable
z = 0:0.5:10; % third dimension independent variable
[X, Y, Z] = meshgrid(x, y, z);
data=% form the 3D data grid
% form the data matrix - it is the fourth dimension
% the data could be imported from a file or could be generated via equation
data = abs(cos(X) + cos(Y) + cos(Z));
[data]= meshgrid(D,D,D);
% plot the data
figure(1)
scatter3(X(:), Y(:), Z(:), 20, data(:), 'filled')
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
xlabel('X')
ylabel('Y')
zlabel('Z')
colorbar