# Apply matrixform to limited rows and columns of a matrix

I have a big matrix, you can say 1000*1000 whose elements are functions of several parameters such as a, b. I wish to see just a few (not all) rows and columns of the matrix in the MatrixForm which is a builtin function of Mathematica. For instance, row from 92 to 101 and column corresponded with 50 to 65. How can I reach this goal? In addition, if I want to simplify the elements, should I simply firstly and after that make use of MatrixForm or should I do vise versa? Which one is faster to run?

Here is a function that shows a portion of a matrix in MatrixForm, with associated row and column indices:

iMatrixView[m_, r_List, c_List] := Module[{sub = m[[r, c]]},
augmented = ArrayFlatten[{
{Map[Invisible, sub, {2}], List /@ istyle /@ r},
{{istyle /@ c}, ""}
}];
Overlay[{
Row[{RawBoxes@"(", Grid[sub, Spacings->1],RawBoxes@")"}],
Row[{Invisible[RawBoxes@"("],Grid[augmented, Spacings->1]}]
}]
]

istyle[x_] := Style[x, Gray, FontSize->Inherited-3]


For example:

SeedRandom
mat = RandomInteger[150, {10, 15}];
iMatrixView[mat, {2,4,5}, {1, 6, 12}] It is possible to use this function in a Manipulate to interactively explore the matrix:

MatrixView[mat_?MatrixQ, rows_Integer?Positive, cols_Integer?Positive] := With[
{dim=Dimensions[mat]},

Manipulate[
iMatrixView[
mat,
Reverse[dim[]+1-Range[rows]-u[]],
Range[cols]+u[]
],
{{u, {0,dim[]-rows}}, {0,0}, Reverse@dim-{cols,rows}, 1}
] /; rows<dim[]&&cols<dim[]
]


For example:

MatrixView[mat, 6, 5] • Wonderful and Professional. Thanks so much – Inzo Babaria Apr 21 '19 at 1:32
M = RandomInteger[10, {1000, 1000}];
M // MatrixForm;

SubM = M[[92 ;; 101 , 50 ;; 65]];
SubM // MatrixForm


In terms of simplifying, it depends on a few things. Assuming that you only want to simplify the entries that you're extracting I think it'd be quicker to extract first, then simplify. If you simplify first then extract I'd think its almost equivalent to extracting twice since you first need to tell the computer which cells you want to simplify, which takes some time, then simplify them, then extract them, when if you extract them first and then simplify the whole thing, there are only two operations required, which logically should be quicker. Hope that helps.

• your answer helped me fundamentally. Thank you so much – Inzo Babaria Apr 21 '19 at 1:31