k-Wave Toolbox |

# makeGrid

Create k-space 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

## Examples

- Homogenous Propagation Medium
- Using A Binary Sensor Mask
- Loading External Image Maps
- Heterogeneous Propagation Medium
- Saving Movie Files
- Recording The Particle Velocity
- Defining A Gaussian Sensor Frequency Response
- Comparison Of Modelling Functions
- Setting An Initial Pressure Gradient
- Simulations In One Dimension
- Simulations In Three Dimensions
- Photoacoustic Waveforms in 1D, 2D and 3D
- Monopole Point Source In A Homogeneous Propagation Medium
- Dipole Point Source In A Homogeneous Propagation Medium
- Simulating Transducer Field Patterns
- Steering A Linear Array
- Snells Law And Critical Angle Reflection
- The Doppler Effect
- Diffraction Through A Slit
- Simulations In Three-Dimensions
- Focussed Detector in 2D
- Focussed Detector in 3D
- Modelling Sensor Directivity in 2D
- Modelling Sensor Directivity in 3D
- Sensor Element Directivity in 2D
- Focussed 2D Array with Directional Elements
- 2D FFT Reconstruction For A Line Sensor
- 3D FFT Reconstruction For A Planar Sensor
- 2D Time Reversal For A Line Sensor
- 2D Time Reversal For A Circular Sensor
- 3D Time Reversal For A Planar Sensor
- 3D Time Reversal For A Spherical Sensor
- Image Reconstruction With Directional Sensors
- Image Reconstruction With Bandlimited Sensors
- Image Reconstruction With Compensation For Acoustic Absorption
- Controlling The Absorbing Boundary Layer
- Source Smoothing
- Filtering A Delta Function Input Signal
- Modelling Power Law Absorption
- Optimising k-Wave Performance

## See Also

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

© 2009, 2010, 2011 Bradley Treeby and Ben Cox.