I have a matrix $X$ and a vector $y$, how do I solve the following equation for $w$:
$ X^{T}Xw = X^{T}y $
in Octave and/or MATLAB?
I have a matrix $X$ and a vector $y$, how do I solve the following equation for $w$:
$ X^{T}Xw = X^{T}y $
in Octave and/or MATLAB?
You don't have to worry about multiplying by $X^T$ to get a square matrix. Just type "X\y"
The literal translation of $w = (X^{T}X)^{-1}X^{T}y$ is
w = inv(X * X') * X' * y or better w = linsol(X*X', X'*y)
but you should better use lsqlin see Emre's answer.