I need to solve in Matlab a Least squares problem,
\begin{equation} \begin{bmatrix} x^2 \\ ux \\ u^2 \end{bmatrix}^T\begin{bmatrix} H_{xx} \\ 2H_{xu} \\ H_{uu} \end{bmatrix} = y \end{equation}
Set $z= \begin{bmatrix} x^2 \\ ux \\ u^2 \end{bmatrix}$, $H = \begin{bmatrix} H_{xx} \\ 2H_{xu} \\ H_{uu} \end{bmatrix}$, where $H$ is the vector of unknowns. As I have q=3 unknowns, I need to collect at least $N\geq q$ data samples: \begin{equation} \Phi = [z^1 \ z^2 \ z^3] \end{equation} where the data are collected such that the rank condition is satisfied (rank($\Phi$)=q) and \begin{equation} Y = \begin{bmatrix}y^1 \\ y^2 \\ y^3\end{bmatrix} \end{equation} The Least squares solution is then \begin{equation} H = (\Phi^T\Phi)^{-1}\Phi^T Y \end{equation}
However, the computed H is too big and cannot converge to the true value. This is probably because the matrix $\Phi$ is ill-conditioned (indeed cond(Phi) returns a number of order e+03). What am I missing?
This is the reference I am using: see Algorithm 2
Solved: there was a mistake in the collection of datasample $z^{i}$, so even though the rank condition was satisfied, its inverse was almost singular (indeed the condition number was very high).
ans =
-0.5609 + 0.0000i, 0.1212 + 0.2634i, 0.1212 - 0.2634i,
– Betelgeuse May 29 '19 at 13:18