# How do you convert this diagram into a linear system of equations/matrix form?

Question: Given is the following pipe system:

the pressure in a stationary state is at every end and cross-point (with exception of $K_i, i ={1,...,4}$) equal to the average pressure of the neighboring points. On $K_i$ with $i = \{1,...,4\}$ are valves with fixed pressure of $K_i = 10i$.

a) Create a system of linear equations to represent the values of the pressure on the points. b) Turn this system of linear equations into a matrix-vector representation. c) Solve this system of linear equations with matlab.

I'm having a lot of difficulty for some reason. I'm not sure if I'm on the right track by numbering the points from top left to bottom right as one does a matrix ($a_{ij}$). I believe the resulting equations would be somthing like:

$a_{11} = \frac{1}{3}(40 + a_{12}+a_{21})$

$a_{21} = \frac{1}{3}(a_{11} + a_{22} +a_{31})$

$a_{31} = \frac{1}{3}(a_{21} + a_{32} + a_{41})$

$a_{41} = \frac{1}{3}(10 +a_{31} +a_{42})$

and the 6 points in the middle would be of the form:

$a_{22} = \frac{1}{4}(a_{12} + a_{21} + a_{23} + a_{32})$

I don't see how I can put this into a matrix-vector form. Everytime that I try to use substitution(say $a_{11}$ into the equation for $a_{21}$ I am not sure which direction to go and I am thinking that I must be misunderstanding something.

At first I was visualising such a matrix equation:

$\left ( \begin{array}{ccccc} a_{11} & a_{12} &a_{13} &a_{14} &a_{15} \\a_{21} & a_{22} & a_{23} & a_{24} & a_{25} \\ a_{31}& a_{32}& a_{33}& a_{34}& a_{35} \\ a_{41}& a_{42}& a_{43}& a_{44}& a_{45}\end{array}\right ) \left( \begin{array}{c}x_1\\ x_2 \\ x_3 \\ x_4 \\ x_5 \end{array}\right ) = \left( \begin{array}{c} 40 \\ 30 \\ 20 \\ 10\end{array} \right)$

however, I think this must be nonsense, there are 5 unknowns and only 4 'equations'. I am assuming though, that I will be using the matlab "linsolve(A,b)" command, right? I am not even sure at this point what the $A$ and $b$ will be in this simple equation... If anyone could help me start getting this straight I would really appreciate it!

-

That is, the unknowns are $a_{11},\ldots,a_{45}$; these are not the coefficients of the matrix of the system.
@user3711: Yes: your vector of unknowns will have the $a_{ij}$ in it in an appropriate order. The $\mathbf{b}$ vector should contain only four nonzero entries, corresponding to the equations you get from looking at each of the corners. As this will be a $20\times 20$ system, it is no surprise you are being told to solve it using MatLab (as opposed to by hand)! – Arturo Magidin Jan 31 '11 at 17:52