In Matlab! For example, your vector for some n: n = 5; v = 1:n*(n+1)/2; An your matrix M = fliplr(triu(ones(n))); M(logical(M)) = v; Ciao