- never ever use ^(-1) or inv to solve a linear system. Backslash operator is faster and more accurate.
- the transpose operator is .' for the transpose. A simple ' is the complex conjugate transpose. In your case this is not affecting the result, but it is a good practice to keep the two operations separated.
- Note that you can solve the least-square problem without explicitly write the normal equations using the backslash operator on your overdetermined system