[Math] Equation of hyperplane in Matlab

computational geometrygeometrylinear algebraMATLAB

Given $n$ points in $n$-dimensions, using MatLab, how should we find the equation of the $(n-1)$-dimensional hyperplane passing through these $n$ points.

Best Answer

Let the given points be $$ p_1 = \left[\begin{matrix} p_{11} \\ p_{12} \\ \vdots \\ p_{1n} \end{matrix}\right] \quad\text{,}\quad p_2 = \left[\begin{matrix} p_{21} \\ p_{22} \\ \vdots \\ p_{2n} \end{matrix}\right] \quad\text{,}\quad \dots \quad\text{,}\quad p_n = \left[\begin{matrix} p_{n1} \\ p_{n2} \\ \vdots \\ p_{nn} \end{matrix}\right] $$ You want to find $a_1,\dotsc,a_n,c$ such that the equation $$ a_1 x_1 + \dotsc + a_n x_n = c $$ is satisfied by all the $p_i$. In other words, you want the $a_i$ and $c$ to be a solution of $$ \left[\begin{matrix} p_{11} & p_{12} & \dots & p_{1n} & -1 \\ p_{21} & p_{22} & \dots & p_{2n} & -1 \\ & \vdots \\ p_{n1} & p_{n2} & \dots & p_{nn} & -1 \\ \end{matrix}\right] \left[\begin{matrix} a_1 \\ a_2 \\ \vdots \\ a_n \\ c \end{matrix}\right] = \left[\begin{matrix} 0 \\ 0 \\ \vdots \\ 0 \\ 0 \end{matrix}\right] $$ So, tell Matlab to solve that system... however you tell Matlab to do such things.

Related Question