<< pow2db | FOSSEE_Signal_Processing_Toolbox | prony >>

FOSSEE_Signal_Processing_Toolbox >> FOSSEE_Signal_Processing_Toolbox > prepad

# prepad

Prepend or truncate a vector or matrix to a specified length.

### Syntax

    res = prepad(x, l)
    res = prepad(x, l, c)
    res = prepad(x, l, c, dim)

### Parameters

x:

  Input vector or matrix.

l:

  Desired length (scalar).

c:

  (optional) Scalar value to prepend. Default is 0.

dim:

  (optional) Dimension along which to operate. Default is 2.

### Description

The `prepad` function prepends the scalar value `c` to the vector or matrix `x` until it reaches the specified length `l`. If `c` is not provided, a value of 0 is used. If the length of `x` exceeds `l`, elements are removed from the beginning of `x` to match the desired length. If `x` is a matrix, the operation is performed along rows or columns based on the `dim` parameter.

### Examples

    // Prepend zeros to a row vector to make its length 6
    res1 = prepad([1, 2, 3, 4], 6)

### Authors

- Abinash Singh

Report an issue
<< pow2db | FOSSEE_Signal_Processing_Toolbox | prony >>