0
$\begingroup$

I have a system of linear equations in the following form. How can I solve it in Matlab?

$$\operatorname*{argmin}_{a,b} \sum_{i,j} [X(i,j)-a\times Y(i,j)-b]^2$$

Where X and Y are known. I need to estimate a and b - which do not depend on (i,j).

$\endgroup$
7
  • $\begingroup$ The solution is $a=b=c=0$. You don't have to use anything to calculate it. I suspect you have an error in your setting. $\endgroup$ Aug 11, 2014 at 16:28
  • $\begingroup$ Thanks for your comment. I have modified the function. $\endgroup$
    – user570593
    Aug 11, 2014 at 16:33
  • $\begingroup$ Your expression doesn't depend on $a$. $\endgroup$ Aug 11, 2014 at 16:36
  • $\begingroup$ sorry. modified again. $\endgroup$
    – user570593
    Aug 11, 2014 at 16:37
  • $\begingroup$ Now it doesn't depend on $c$. $\endgroup$ Aug 11, 2014 at 16:37

1 Answer 1

1
$\begingroup$

Let $A = \begin{bmatrix}Y(1,1) & 1 \\ Y(2,1) & 1 \\ \vdots & \vdots \\ Y(m,n) & 1 \end{bmatrix}$, $y = \begin{bmatrix}X(1,1) \\ X(2,1)\\ \vdots \\ X(m,n)\end{bmatrix}$, and $x = \begin{bmatrix}a \\ b\end{bmatrix}$.

Then, the problem can be rewritten as $\text{argmin}_{x}\|y-Ax\|_2^2$.

This is now the standard linear least squares problem. The solution is $\hat{x} = (A^TA)^{-1}A^Ty$.

$\endgroup$
1
  • 1
    $\begingroup$ in MATLAB notation, it would be A\y. $\endgroup$
    – Memming
    Aug 11, 2014 at 17:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .