k-Wave Toolbox |

# makeGrid

Create k-space grid structure

## Syntax

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

## Description

`makeGrid` creates a MATLAB structure containing the grid coordinates and wavenumber matrices for use in k-space simulations and reconstructions. Note, the grid structures are indexed as: (x) in 1D; (z, x) in 2D; (z, x, y) in 3D.

## Inputs

`Nx, Ny, Nz` | number of pixels in each Cartesian direction
`dx, dy, dz` | pixel size in each Cartesian direction [m]

## Outputs

`kgrid` | k-space 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

And for each spatial dimension x, y, z:

Fieldname | Description
--- | ---
`kgrid.Nx` | number of pixels
`kgrid.dx` | size of an individual pixel [m]
`kgrid.x` | plaid ND grid of the x coordinate centered about 0 [m]
`kgrid.x_off` | plaid ND grid of the x coordinate beginning at 0 [m]
`kgrid.x_size` | length of grid dimension [m]
`kgrid.kx` | plaid ND grid of the wavenumber components centered about 0

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

    kgrid =

        Nz: 128
        dz: 0.1000
        Nx: 128
        dx: 0.1000
        x_size: 12.8000
        z_size: 12.8000
        z: [128x128 double]
        x: [128x128 double]
        z_off: [128x128 double]
        x_off: [128x128 double]
        kz: [128x128 double]
        kx: [128x128 double]
        k: [128x128 double]

## Examples

- Homogeneous Propagation Medium Example
- Using A Binary Sensor Mask Example
- Loading External Image Maps Example
- Heterogeneous Propagation Medium Example
- Saving Movie Files Example
- Controlling The Absorbing Boundary Layer Example
- Simulations In One-Dimension Example
- Simulations In Three-Dimensions Example
- 2D FFT Reconstruction For A Line Sensor Example
- 3D FFT Reconstruction For A Planar Sensor Example
- 2D Time Reversal Reconstruction For A Line Sensor Example
- 2D Time Reversal Reconstruction For A Circular Sensor Example
- 3D Time Reversal Reconstruction For A Planar Sensor Example
- 3D Time Reversal Reconstruction For A Spherical Sensor Example
- Optimising k-Wave Performance Example

## See Also

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

© 2009 Bradley Treeby and Ben Cox.