Yes, repmat is a simple solution and maybe even the right solution. But knowing how to visualize your goal and how to create something that gives this goal will provide long-term benefits in MATLAB. So try other solutions. For instance...
cumsum(ones(100),2)
bsxfun(@plus,zeros(100,1),1:100)
ones(100,1)*(1:100)
cell2mat(repmat({1:100},100,1))
and boring
repmat(1:100,100,1)
user85109
source
share