%Lab 2
%Written by Jeannette Spuhler, 2011-09-19
%modified 2011-11-03

%minstakvadratmetoden
%NUM4.4
clear all; clc;
A = [   1 2;
        1 4;
        1 7;
        1 9];
    
y = [3 6 7 10]';
x = A\y; 
disp(['Coefficient a has value ', num2str(x(1)), ' and coefficient b has value ',  num2str(x(2))]);

xfun = 1:0.01:10;
yfun = x(1)+x(2)*xfun;
plot(A(:,2), y, '*', xfun, yfun);
title('Lab2 - Minstakvadratmetoden'); 
ylabel('y');
xlabel('x');
