0
$\begingroup$

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?

  • 0
    @Landscape I have posted a question on [meta](http://meta.math.stackexchange.com/questions/9602/should-questions-on-matrices-and-matrix-equations-be-also-tagged-as-linear). Perhaps it would be better to discuss the issue there before starting some kind of editing/retagging war between several users.2013-05-17

2 Answers 2

2

You don't have to worry about multiplying by $X^T$ to get a square matrix. Just type "X\y"

1

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.