Question 24.5: Use the finite-difference approach to solve the same problem...

Use the finite-difference approach to solve the same problem as in Examples 24.1 and 24.2. Use four interior nodes with a segment length of Δ x = 2 m.

Employing the parameters in Example 24.1 and Δ x = 2 m, we can write Eq. (24.16) for each of the rod’s interior nodes. For example, for node 1:
-T_{i-1}+\left(2+h^{\prime} \Delta x^2\right) T_i-T_{i+1}=h^{\prime} x^2 T_{\infty}         (24.16)
−T_0 + 2.2T_1 − T_2 = 40
Substituting the boundary condition T_0 = 300 gives
2.2T_1 − T_2 = 340
After writing Eq. (24.16) for the other interior nodes, the equations can be assembled in matrix form as
\left[\begin{array}{cccc}2.2 & -1 & 0 & 0 \\-1 & 2.2 & -1 & 0 \\0 & -1 & 2.2 & -1 \\0 & 0 & -1 &2.2\end{array}\right]\left\{\begin{array}{c}T_1 \\T_2 \\T_3 \\T_4\end{array}\right\}=\left\{\begin{array}{c} 340 \\40 \\40 \\ 440\end{array}\right\}
Notice that the matrix is both tridiagonal and diagonally dominant.
MATLAB can be used to generate the solution:

>> A = [2.2 −1 0 0;
−1 2.2 −1 0;
0 −1 2.2 −1;
0 0 −1 2.2];
>> b = [340 40 40 440]';
>> T = A\b
T =
283.2660
283.1853
299.7416
336.2462

Related Answered Questions