This may be a trivial question, but I have been at it for a couple of hours and I have not made much progress. I have a 10 x 10 array (T) that I have used to generate an 8 x 8 array (Q). I want to replace the interior of array T with array Q. I can think of lots of really cumbersome ways to do this, but I assume that there is a "good" way to do this...
I suspect that this can be done using ReplaceAll
but I cannot get the form correct.
Any pointers would be greatly appreciated.
The code and arrays are:
Nx = 10;
Ny = 10;
(* Initial Temperature Array *)
T = Table[0, {i, Nx}, {j, Ny}];
T[[1]] = Table[Tbottom, {i, Nx}];
T[[Ny]] = Table[Ttop, {i, Nx}];
T[[All, 1]] = Tleft;
T[[All, Nx]] = Tright;
(* Finite Difference of Array *)
Q = Table[
0.25*(T[[i - 1, j]] + T[[i, j + 1]] + T[[i + 1, j]] +
T[[i, j - 1]]), {i, 2, Nx - 1}, {j, 2, Ny - 1}];
(* Output in Matrix Form *)
T // MatrixForm
Q // MatrixForm
Array T $$ \left( \begin{array}{cccccccccc} 50 & 50 & 50 & 50 & 50 & 50 & 50 & 50 & 50 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 50 \\ 50 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 100 & 50 \\ \end{array} \right) $$
Array Q $$ \left( \begin{array}{cccccccc} 25. & 12.5 & 12.5 & 12.5 & 12.5 & 12.5 & 12.5 & 25. \\ 12.5 & 0. & 0. & 0. & 0. & 0. & 0. & 12.5 \\ 12.5 & 0. & 0. & 0. & 0. & 0. & 0. & 12.5 \\ 12.5 & 0. & 0. & 0. & 0. & 0. & 0. & 12.5 \\ 12.5 & 0. & 0. & 0. & 0. & 0. & 0. & 12.5 \\ 12.5 & 0. & 0. & 0. & 0. & 0. & 0. & 12.5 \\ 12.5 & 0. & 0. & 0. & 0. & 0. & 0. & 12.5 \\ 37.5 & 25. & 25. & 25. & 25. & 25. & 25. & 37.5 \\ \end{array} \right) $$