Prev Next expand

Expand Matrix Rows by Sample-Repetition
Syntax y = expand(x, factor)
Include: include spt\expand.oms
See Also

ARGUMENTS:
   INPUTS:  
      x      = MATRIX, any numerical type
      factor = SCALAR, any numerical type, coerced to INTEGER
               before processing. Represents the number of 
               times each input value is to be repeated.
   RETURN: MATRIX, expanded version of input vector.

Description

Input matrix 'x' is expanded to row dimension 'factor' times the row dimension of 'x'; column dimension is unchanged. Each element of the columns of 'x' are repeated 'factor' times consecutively in the output. (In the special case where 'x' is a row vector, each element is repeated 'factor' times consecutively and the output is also a row vector). 'factor' is coerced to INTEGER before local processing. The value factor=0 returns the 'x' input unmodified. For factor<0, 'novalue' is returned with a printed error message. Returned type is the same as type of 'x' input. A common use for this function is to expand a vector of data symbols into a time vector where each symbol has a duration of 'factor' samples. If a single scalar is input, returned vector is a column vector.

Example

For Scalar Input:

O>expand(2,5)
{
 2
 2
 2
 2
 2
}

For Row Vectors:

O>x = [1,2,3]
O>expand(x,3)
[  1 ,  1 ,  1 ,  2 ,  2 ,  2 ,  3 ,  3 ,  3 ] 

For Column Vectors:

O>x = {5,6}
O>x
{
 5
 6
}

O>expand(x,2)
{
 5
 5
 6
 6
}

For Matrices:

O>x = seq(3)*seq(4)'
O>x
{
[  1 ,  2 ,  3 ,  4 ]
[  2 ,  4 ,  6 ,  8 ]
[  3 ,  6 ,  9 , 12 ]
}

O>expand(x,3)
{
[  1 ,  2 ,  3 ,  4 ]
[  1 ,  2 ,  3 ,  4 ]
[  1 ,  2 ,  3 ,  4 ]
[  2 ,  4 ,  6 ,  8 ]
[  2 ,  4 ,  6 ,  8 ]
[  2 ,  4 ,  6 ,  8 ]
[  3 ,  6 ,  9 , 12 ]
[  3 ,  6 ,  9 , 12 ]
[  3 ,  6 ,  9 , 12 ]
}