I have a matrix A
like
1 2 3 4 5
6 7 8 9 0
and I want to expand it with a row of ones to get
1 1 1 1 1
1 2 3 4 5
6 7 8 9 0
I create the row of ones with
col_size = size(A, 2);
ones_row = ones(1, col_size);
How can I add my ones_row
to the matrix?
Once you have A
and ones_row
you do:
[ones_row; A]
This returns the following.
1 1 1 1 1
1 2 3 4 5
6 7 8 9 0