k-Wave Toolbox |

# makeGrid

Create k-Wave grid structure

## Syntax

    kgrid = makeGrid(Nx, dx)
    kgrid = makeGrid(Nx, dx, Ny, dy)
    kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz)

## Description

`makeGrid` creates an object of the `kWaveGrid` class containing the grid coordinates and wavenumber matrices used in k-Wave simulations. The grid structures are indexed as: (x, 1) in 1D; (x, y) in 2D; (x, y, z) in 3D.

Note For older versions of MATLAB in which custom class definitions are not supported, `makeGrid` returns a MATLAB grid structure with the same fields. This structure requires additional memory compared to an object of the `kWaveGrid` class.

## Inputs

`Nx, Ny, Nz` | number of grid points in each Cartesian direction
`dx, dy, dz` | grid point spacing in each Cartesian direction [m]

## Outputs

`kgrid` | k-Wave grid structure used by the simulation and reconstructions functions within k-Wave

The structure `kgrid` has the following fields:

Fieldname | Description
--- | ---
`kgrid.k` | ND grid of the scalar wavenumber
`kgrid.k_max` | maximum spatial frequency supported by the grid
`kgrid.t_array` | evenly spaced array of time values [s] (set to 'auto' by `makeGrid`)
`kgrid.Nt` | number of time steps (set to 'auto' by `makeGrid`)
`kgrid.dt` | time step [s] (set to 'auto' by `makeGrid`)
`kgrid.dim` | number of spatial dimensions
`kgrid.total_grid_points` | total number of grid points

And for each spatial dimension x, y, z:

Fieldname | Description
--- | ---
`kgrid.Nx` | number of grid points
`kgrid.dx` | grid point spacing [m]
`kgrid.x` | plaid ND grid of the x coordinate centered about 0 [m]
`kgrid.x_vec` | 1D vector of the x coordinate [m]
`kgrid.x_size` | length of grid dimension [m]
`kgrid.kx` | plaid ND grid of the wavenumber components centered about 0
`kgrid.kx_vec` | 1D vector of the wavenumber components
`kgrid.kx_max` | maximum spatial frequency supported by the grid in the x direction

For example, running `kgrid = makeGrid(128, 0.1, 128, 0.1)` at the command line will return:

    kgrid = makeGrid(128, 0.1, 128, 0.1)

    kgrid =

      kWaveGrid

      Properties:
                       Nx: 128
                       Ny: 128
                       Nz: 0
                       dx: 0.1000
                       dy: 0.1000
                       dz: 0
                   kx_vec: [128x1 double]
                   ky_vec: [128x1 double]
                   kz_vec: 0
                        k: [128x128 double]
                   kx_max: 31.4159
                   ky_max: 31.4159
                   kz_max: 0
                    k_max: 31.4159
                  t_array: 'auto'
                      dim: 2
                        x: [128x128 double]
                        y: [128x128 double]
                        z: 0
                       kx: [128x128 double]
                       ky: [128x128 double]
                       kz: 0
                    x_vec: [128x1 double]
                    y_vec: [128x1 double]
                    z_vec: 0
                   x_size: 12.8000
                   z_size: 0
                   y_size: 12.8000
                       dt: 'auto'
                       Nt: 'auto'
        total_grid_points: 16384

## See Also

`cart2grid`, `interpCartData`, `kspaceFirstOrder1D`, `kspaceFirstOrder2D`, `kspaceFirstOrder3D`, `ndgrid`, `makeTime`, `smooth`

© 2009-2014 Bradley Treeby and Ben Cox.