MATLAB: How to create a 1,12,123,1234 pattern in a triangle

looppattern

How do I make a pattern from 1:N, Lets say N = 5, so it turns out like this:
1
12
123
1234
12345

Best Answer

Use a loop or
n = 5;
c = arrayfun(@(nn) 1:nn, (1:n)', 'UniformOutput', false);
celldisp(c)
You obviously can't store the result in a matrix since matrices are square by definition.