how can I add, for example vector
v1 = [0 0 0 1]
v2 = [0 1 0 0]
so that I get an array
a = 0 0 0 1
0 1 0 0
and also add more vectors to, into array a
?
how can I add, for example vector
v1 = [0 0 0 1]
v2 = [0 1 0 0]
so that I get an array
a = 0 0 0 1
0 1 0 0
and also add more vectors to, into array a
?
if you have 2 row vectors v1 = [0 0 0 1], and v2 = [0 1 0 0]
v3 = [v1, v2] yields
v3 = [ 0 0 0 1 0 1 0 0 ]
v3 = [v1; v2] yields
v3 =
[ 0 0 0 1
0 1 0 0 ]
A part from the prior answers I suggest that you check the following functions: horzcat, vertcat and reshape.
For instance test this code:
A1 = [1 2 3; 4 5 6; 7 8 9];
A2 = A1 + 10*ones(3,3);
B1 = horzcat(A1,A2) % horizontal concatenation
B1 = vertcat(A1,A2) % vertical concatenation
v1 = reshape(A, 1, prod(size(A))) % easily change the size of matrix
Just concatenate them by using the following syntax:
a = [v1 v2]
Hope this works