vec2mat

Converts a vector, v, to a matrix with the specified number of columns, c.

Syntax

R = vec2mat(v, c)

R = vec2mat(v, c, val)

[R, count] = vec2mat(v, c,...)

Inputs

v
Type: vector
c
Number of columns in the output matrix, R.
Type: Finite, positive integer
val (optional)
Specifyies the values that matrix R is padded with so that it is the correct size. By default, the value of val is 0.
Type: scalar | integer | complex

Outputs

R
Matrix with the contents of m, with the number of columns, c. val is used to pad R so that it is of the correct size.
Type: matrix
count (optional)
Output which gives a count of val that was used to pad R so that it has the correct size.
Type: matrix

Examples

Vector to matrix with default values padded:
R = vec2mat([1,2,3,4,5], 2)
R = [Matrix] 3 x 2
1  2
3  4
5  0
Vector to matrix with padded value specified:
R = vec2mat([1,2,3,4,5], 2, 24)
R = [Matrix] 3 x 2
1   2
3   4
5  24
Vector to matrix with a count of padded values:
[R, count] = vec2mat([1,2,3,4,5], 4, 100)
R = [Matrix] 2 x 4
1    2    3    4
5  100  100  100
count = 3