Question: Quickly constructing lower triangular matrix

How can I quickly construct a lower triangular matrix?

I tried the following:

restart;

n := 4;

M1 := Matrix(Vector([seq(k, k = 1 .. n)]), shape = diagonal);

M2 := Matrix(Vector([seq(1, k = 1 .. n-1)]), shape = diagonal);

M := Matrix([M1, M2], shape = triangular[lower])

 

 

 

In this case the diagonal has value 1,2,3,4 while the line below 1,1,1.

 

edit: Actually I managed with

M := Matrix([[1], seq([seq(0, i = 1 .. k-2), 1, k], k = 2 .. n)], shape = triangular[lower])

 

 

 

but I was wondering if it is also possible to use Matrices to fill parts of a bigger matrix?

Please Wait...