I'm comparing data to a theory I've developed and right now I have to do some parameter fitting. Say I have two unknown parameters $x$ and $y$ such that $a_{1}x+b_{1}y=c_{1}$, $a_{2}x+b_{2}y=c_{2}$, $a_{3}x+b_{3}y=c_{3}$ and $a_{4}x+b_{4}y=c_{4}$, where the $a_{i}$ and $b_{i}$ constants are known. How can I obtain the values of $x$ and $y$ that make the left sides of these equations be closer to the right sides?
Sorry if the question is a little ambiguous but it's the first time I've done this kind of fitting. I have no idea of what to do, as I have 4 equations and 2 unknowns and the system is clearly incompatible. I can start playing with the parameters until I'm satisfied, but there must be a better way.
You can find a least squares estimate of $x$ and $y$.
You want to "solve" the overdetermined system $Az = c$, where \begin{equation} A = \begin{bmatrix} a_1 & b_1 \\ a_2 & b_2 \\ a_3 & b_3 \\ a_4 & b_4 \end{bmatrix} \end{equation} and \begin{equation} c = \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \end{bmatrix}. \end{equation} In a least squares approach you pick the solution $z = \begin{bmatrix} x \\ y \end{bmatrix}$ that minimizes $\| Az - c \|_2^2$. We can minimize this function by setting the gradient equal to $0$, which yields: \begin{equation} A^T(Az - c) = 0. \end{equation} This system of equations is called the "normal equations". Now you can just solve for $z$.
In Matlab, the answer is given by the command
z = A\b;