.php xmlns="http://www.w3.org/1999/.php"> - k-Wave MATLAB Toolbox
k-Wave Toolbox

trimZeros

Create a tight bounding box by removing zeros.

Syntax

data = trimZeros(data)
[data, ind] = trimZeros(data)

Description

trimZeros reduces the size of a matrix to create a tight bounding box around the data by removing zeros. For example, in 2D, if the input data is given by

    0 0 0 0 0 0
    0 0 0 3 0 0
    0 0 1 3 4 0
    0 0 1 3 4 0
    0 0 1 3 0 0
    0 0 0 0 0 0

trimZeros will return

    0 3 0
    1 3 4
    1 3 4
    1 3 0

Inputs

data matrix to trim

Outputs

data trimmed matrix
ind indices used to trim matrix

See Also

resize, expandMatrix
<.php>