math - How to join the same matrix several times to make a big matrix in Matlab? -
i have 4x1 matrix,
a= [1;2;3;4]
i want make b
such size 4x50. elements in columns must contain same elements of a. example,
b= [1 1 1 1.... 1 1; 2 2 2 2.... 2 2; 3 3 3 3.... 3 3; 4 4 4 4.... 4 4]
in case elements of column 1 present in same way in first column of b, same second column on b, , on
is there way form b a? trying concatenating below:
b= horzcat(a,a,...);
but in case, have write a
, 50 times. there other way same result?
have tried using repmat
?
b = repmat(a, 1, 50);
repmat
(which nicely stands repeat matrix) takes matrix , repeats many times horizontally , vertically want. technically speaking, can choose how many times want repeat many dimensions possible there in matrix. however, our purposes here, matrix has 2 degrees of freedom / dimensions, we're considering horizontal , vertical here.
in specific case, want repeat column vector 50 times horizontally, hence third parameter being set 50, while want 1 copy vertically, hence second parameter being set 1.
Comments
Post a Comment