A clumsy, but generic one-liner
n = 3; %number of elements in A;
m = 5; %repetitions
A = (1:n);
B = full( spdiags( repmat(A(:),1,m)' , 1-(1:n) , n+m-1, m) )
returns:
B =
1 0 0 0 0
2 1 0 0 0
3 2 1 0 0
0 3 2 1 0
0 0 3 2 1
0 0 0 3 2
0 0 0 0 3
Alternatively an improved, generic version of rubenvb's solution
B = toeplitz( [A(:);zeros(m-1,1)] , zeros(1,m) )
in both cases A
can be either a row or column vector.
The faster solution (factor 2x) is the first one with spdiags
!
Edit: even clumsier, but up to 10x faster (it depends on n,m) than the toeplitz
-approach:
B = reshape( [repmat([A(:);zeros(m,1)],m-1,1) ; A3(:)] ,[],m )