# Linear algebra with a linear model (Matlab)

Given the equation

$$r = B + e(r\cos(\theta))$$

and the corresponding data:

$\theta: 0.88; 1.1; 1.42; 1.77; 2.14$ and $r: 3; 2.4; 1.65; 1.25; 1.01$

How do you input these data for matlab to solve for $B$ and $e$?

-
You know how to do a linear regression in MATLAB? –  Ｊ. Ｍ. Dec 3 '11 at 6:02
No, I do not. I don't understand the answer given at all. –  Randy Dec 7 '11 at 16:27
You know how to solve a least-squares problem, don't you? –  Ｊ. Ｍ. Dec 7 '11 at 16:28
By hand. I don't see how that applies to this –  Randy Dec 7 '11 at 16:45
Okay, I added a hint to my answer. –  Ｊ. Ｍ. Dec 7 '11 at 16:53

$$\begin{pmatrix}1&r_1\cos\,\theta_1\\1&r_2\cos\,\theta_2\\1&r_3\cos\,\theta_3\end{pmatrix}\begin{pmatrix}B\\e\end{pmatrix}=\begin{pmatrix}r_1\\r_2\\r_3\end{pmatrix}$$