Surface fitting to a mesh grid of data points I wonder if there is a technique for fitting a surface to a given mesh grid of data points? I've seen interpolating a polynomial to $2$D data, but not $3$D. 
E.g. say I was given the matrix $$
H=\left(\begin{array}{cccc}
1 & 32 & 245 & 45 \\
5 & 145 & 134 & 54 \\
9 & 2 & 67 & 24\\
12 & 99 & 121 & 201
\end{array}\right),
$$ 
could I construct a function $f(x,y)=z$ where $x,y$ are the discrete points and $z$ is the corresponding matrix value? Many thanks. 
 A: Try bicubic Bézier surface patch.
$z=f(u,v)=U\cdot C\cdot P\cdot C\cdot V^T$, 
where $U=[u^3\ u^2\ u\ 1],\ V=[v^3\ v^2\ v\ 1]$, 
$C=\left[\begin{array}{cccc}
 -1 &  3 & -3 & 1 \\
  3 & -6 &  3 & 0 \\
 -3 &  3 &  0 & 0 \\
  1 &  0 &  0 & 0 
\end{array}\right]$, 
$P=\left[\begin{array}{cccc}
P_{00} & P_{01} & P_{02} & P_{03} \\
P_{10} & P_{11} & P_{12} & P_{13} \\
P_{20} & P_{21} & P_{22} & P_{23} \\
P_{30} & P_{31} & P_{32} & P_{33}
\end{array}\right]$.
To find 16 control points $P_{00}\dots P_{33}$,
consider given matrix
$H=\left[\begin{array}{cccc}
1 & 32 & 245 & 45 \\
5 & 145 & 134 & 54 \\
9 & 2 & 67 & 24\\
12 & 99 & 121 & 201
\end{array}\right]=
\left[\begin{array}{cccc}
f(0,0) & f(0,\frac13) & f(0,\frac23) & f(0,1) \\
f(\frac13,0) & f(\frac13,\frac13) & f(\frac13,\frac23) & f(\frac13,1) \\
f(\frac23,0) & f(\frac23,\frac13) & f(\frac23,\frac23) & f(\frac23,1) \\
f(1,0) & f(1,\frac13) & f(1,\frac23) & f(1,1)
\end{array}\right]$.
Hint: it is easier to find the outer points first and then solve 
a system for $P_{11},P_{12},P_{21},P_{22}$.
The picture shows how the function $f(u,v)$ looks like for the given $H$:

