Lab3 Soln

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

EGN 4933 Lab 3

Due end of class, Wednesday, October 6th

1. Develop the equations to be solved to performPa least-squares fit to a linear


N
function. We seek to minimize J(a, b) = i=1 (yi − a · xi − b)2 . Find
the partial derivatives of J with respect to its arguments, and set to 0. In
class, on Monday, we found the following equations:
X X X
xi · yi = a( x2i ) + b( xi )
i i i
X X
yi = a( xi ) + b(N )
i i

2. Use the following data in your equations to find the best fit line:
See accomanying MATLAB script.
xi yi
0 1.8152
0.2222 2.9759
0.4444 3.4456
0.6667 4.2064
0.8889 4.9636
1.1111 6.0551
1.3333 6.7068
1.5556 7.5405
1.7778 8.1022
2.0000 9.0274
3. Use MATLAB to plot the data and the line you computed together on the
same graph. The data is posted on Blackboard as the file,

line.dat

You might also like