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.
- 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.
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.
- count (optional)
- Output which gives a count of val that was used to pad R so that it has the correct size.
Examples
R = vec2mat([1,2,3,4,5], 2)
R = [Matrix] 3 x 2
1 2
3 4
5 0
R = vec2mat([1,2,3,4,5], 2, 24)
R = [Matrix] 3 x 2
1 2
3 4
5 24
[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