Hi please can someone help me writing a program of generating a tridiagonal block matrix with dimension of NxN where N is a variable can be 50, 100, 200, 300...etc , Well I don't know how I'm a beginner. THANK YOU ANYWAY!
1 Answer
$\begingroup$
$\endgroup$
$Version
"13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)"
Clear["Global`*"]
n = 5;
(mat =
ReplacePart[
DiagonalMatrix[ConstantArray[A + W - EI, n]] +
DiagonalMatrix[ConstantArray[-W', n - 1], 1] +
DiagonalMatrix[ConstantArray[-W', n - 1], -1],
{{1, 1} -> A - EI, {n, n} -> A - EI}]) // MatrixForm
IdentityMatrix[n]
. For the rest, improve your question and formatting. $\endgroup$SparseArray
, whose documentation page also shows how to construct a tridiagonal matrix. $\endgroup$