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-Wave 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
`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`)

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]
          k_max: 31.4159
        t_array: 'auto'

## Examples

- Homogeneous Propagation Medium
- Using A Binary Sensor Mask
- Loading External Image Maps
- Heterogeneous Propagation Medium
- Saving Movie Files
- Modelling A Focussed Detector
- Modelling Sensor Directivity
- Simulations In One Dimension
- Simulations In Three Dimensions
- 2D FFT Reconstruction For A Line Sensor
- 3D FFT Reconstruction For A Planar Sensor
- 2D Time Reversal Reconstruction For A Line Sensor
- 2D Time Reversal Reconstruction For A Circular Sensor
- 2D Time Reversal Reconstruction Using Directional Sensors
- 3D Time Reversal Reconstruction For A Planar Sensor
- 3D Time Reversal Reconstruction For A Spherical Sensor
- Point Source In A Homogeneous Propagation Medium
- Simulating Transducer Field Patterns
- Sensor Element Directivity
- Steering A Linear Array
- Snells Law And Critical Angle Reflection
- Simulations In Three-Dimensions
- Controlling The Absorbing Boundary Layer
- Filtering A Delta Function Input Signal
- Optimising k-Wave Performance

## See Also

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

© 2009, 2010 Bradley Treeby and Ben Cox.