I am required to do this problem can I get some help please

I am required to do this problem, can I get some help please?

take at least 10 points (that can be fitted with a linear function) from an open source data base. Find the linear function that gives the best fit to your data by solving the corresponding linear least squares problem (LLSP). Apply the steepest descent algorith with [0, 0] as the starting point to solve the LLSP numerically. Write Matlab code to carry out the iterations. Stop iterations when the norm of the gradient is less than 1e-6. For full credit, please include in your report (a) the source of the data; (b) exact solition of the LLSP computed from FONC; (c) the code and the results arranged in a table; (c) plot of the data and of the straight line constructed.

Solution

Assuming that the database contains the file with 10 numbers, we need to first read the file in matlab using the matlab inbuilt function

% Reading a file in matlab with the data %

%%%%%%%%%%%%%%%%%%%%

Now using the steepest decent algorithm code below

n=0;          % counter value in order to check the number of iterations
eps=1;       % error in the calculation
x=[0;0];       % starting value/ initial guess


while eps>1e-15 & n<200 % Loop Breaking Conditions/ Final Terminating Solution
    g=[x(1)^2+x(2)^2 ; x(1)^2/5 + x(2)^2];       
    eps=abs(g(1))+abs(g(2));                         
    Jg=[2*x(1),2*x(2);4*2*x(1)/5+2x(2)];  
    y=x-Jg\\g;                                          
    x=y;                                            
    n=n+1;                                           
end
n,x,eps,

I am required to do this problem, can I get some help please? take at least 10 points (that can be fitted with a linear function) from an open source data base.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site