Matlab - building a matrix by merging the same raw vector multiple times?

You are looking for the REPMAT function: x = 1 2 2 3; m = repmat(x,4,1) You can also use indexing to repeat the rows: m = x(ones(4,1),:) or even outer-product: m = ones(4,1)*x and also using BSXFUN: m = bsxfun(@times, x, ones(4,1)).

You are looking for the REPMAT function: x = 1 2 2 3; m = repmat(x,4,1); You can also use indexing to repeat the rows: m = x(ones(4,1),:); or even outer-product: m = ones(4,1)*x; and also using BSXFUN: m = bsxfun(@times, x, ones(4,1)).

– Simon Jul 31 at 12:14 1 use the BSXFUN solution: m = bsxfun(@times, x, (1:3)') – Amro Jul 31 at 12:17 If I remember correctly, using indexing is faster than using repmat. But is also much less readable. – MarkV Jul 31 at 16:54.

You could try using vertcat, like this: x = 1 2 2 3; m = vertcat(x,x,x,x); Or even simply: x = 1 2 2 3; m = x;x;x;x; EDIT: for multiples of x, you can do: x = 1 2 2 3; m = x;2*x;3*x; % 1 2 2 3; 2 4 4 6; 3 6 6 9 EDIT2: For an arbitrary number of x's in m... n = 3; % number of repetitions... x = 1 2 2 3; m = ; for i=1:n m = m;x; end.

The problem is that I want to pass an argument with the number of multiples. I want to do this inside a for loop and the number of times to concatenate the raw vectors is undetermined. – Simon Jul 31 at 12:18 Ah, you didn't mention that in your question... (I've edited my answer) – Richard Inglis Jul 31 at 12:20.

Browse other questions tagged matlab matrix rows repeating tiling or ask your own question.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions