Я хочу написать функцию, которая создает 3D-сетку с шаром внутри сетки. Это должно быть 3D. Я нашел this example, и это именно то, что я хочу, но я не знаю, как добавить это в функцию m-файла.Matlab: Как я могу создать 3D-сетку?
Это мой код:
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