我想编写一个函数,它创建一个在网格内有一个球的 3D 网格。应该是3D的。我找到了这个例子,这正是我想要的,但我不知道如何将它添加到函数 m 文件中。
这是我的代码:
function kgrid = makeGrid(Nx, dx, Ny, dy);
% create the computational grid
Nx = 64; % number of grid points in the x direction
Ny = 64; % number of grid points in the y direction
Nz = 64; % number of grid points in the z direction
dx = 0.1e-3; % grid point spacing in the x direction [m]
dy = 0.1e-3; % grid point spacing in the y direction [m]
dz = 0.1e-3; % grid point spacing in the z direction [m]
kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);
end