I have written the following Code
Clear[n, d, A, mm, G]; SeedRandom[14]; n = 10; A = Array[RandomReal[{0, 0.5}] &, {n, n}]; mm = SetPrecision[Inverse[IdentityMatrix[n] - A], 2]; selectionMatrix[θ_] := ReplacePart[mm, {i_, i_} -> 0] /. {x_ /; x > θ -> 1, x_ /; x < θ -> 0} // Transpose; v = Table[Subscript[s, i], {i, n}]; g = AdjacencyGraph[selectionMatrix[0.05], VertexLabels -> MapThread[Rule, {Range [Length[v]], v}], ImageSize -> 150, VertexSize -> .9, ImagePadding -> 20]; {selectionMatrix[0.05] // MatrixForm, g} selectionMatrix works just fine for a single parameter theta defining the threshold for creating an adjacency matrix represented as a directed graph. The parameter theta defines a binary selection, i.e., selecting those elements of a matrix that are below or above the theta level.
I want to modify the selectionMatrix function in such a way to create an adjacency matrix for a range of theta such as 0.5<theta<1 or -0.4<theta<0.2 etc. How can I revise selectionMatrix to accomplish this task?



ClearAll[selectionMatrix2]; selectionMatrix2[m_][\[Theta]1_, \[Theta]2_] := Transpose[(1 - UnitStep[\[Theta]1 - m]) (1 - UnitStep[m - \[Theta]2])] - IdentityMatrix[Length@m]? $\endgroup$selectionMatrix2[mm][.5,1]andselectionMatrix2[mm][-.4,.2]$\endgroup$Clip. $\endgroup$mm = {{1, 2, 3, 4}, {0, -1, -2, -3}, {0, 1, -3, 3}, {3, 4, 5, -5}},selectionMatrix2[mm][-2, 2](elements within the range (-2,2) should be all 1, otherwise 0, including diagonals) yields{{0, 1, 1, 0}, {0, 0, 1, 0}, {0, 0, -1, 0}, {0, 0, 0, -1}}, which is wrong. $\endgroup$