Is there a matlab function which allows me to do the following operation?
x = [1 2 2 3];
and then based on x
I want to build the matrix m = [1 2 2 3; 1 2 2 3; 1 2 2 3; 1 2 2 3]
Is there a matlab function which allows me to do the following operation?
x = [1 2 2 3];
and then based on x
I want to build the matrix m = [1 2 2 3; 1 2 2 3; 1 2 2 3; 1 2 2 3]
You could try using
vertcat
, like this:Or even simply:
EDIT:
for multiples of x, you can do:
EDIT2:
For an arbitrary number of x's in m...
You are looking for the REPMAT function:
You can also use indexing to repeat the rows:
or even outer-product:
and also using BSXFUN: