01-26-2019, 11:19 AM

Specifically, I would like to create a matrix, using a 3 element specified pattern, (tridiagonal), with a specified number of rows and columns. The center value of the pattern should be on the main diagonal of the matrix:

Some kind of variation on this (non-working) theme:

makemat([-1,2,-1], 5,5); // Uses the pattern -1,2,-1 in a 5x5 matrix, with 2 on the main diagonal:

[[2,-1,0,0,0],

[-1,2,-1,0,0],

[0,-1,2,-1,0],

[0,0,-1,2,-1],

[0,0,0,-1,2]]

I (think) this can be done using the matlab eye() command, for example. Any ideas how to create a custom matrix in similar fashion, on the prime?

-Dale-

Some kind of variation on this (non-working) theme:

makemat([-1,2,-1], 5,5); // Uses the pattern -1,2,-1 in a 5x5 matrix, with 2 on the main diagonal:

[[2,-1,0,0,0],

[-1,2,-1,0,0],

[0,-1,2,-1,0],

[0,0,-1,2,-1],

[0,0,0,-1,2]]

I (think) this can be done using the matlab eye() command, for example. Any ideas how to create a custom matrix in similar fashion, on the prime?

-Dale-