How to define the following matrix: the order of matrix is n, In other word, I want define the matrix function of n and i represents the imaginary unit.
Very thanks to you
You can define a function like so:
bandMatrix[dim_Integer] := Module[{mat}, mat = SparseArray[{Band[{1, 1}] -> 0, Band[{2, 1}] -> I, Band[{1, 2}] -> I}, {dim, dim}]; mat[[1, dim]] = mat[[dim, 1]] = 1; Return[Normal[mat]] ]