% Ucitavanje podataka
data = load('dataset.txt');
X = data(:, 1);
y = data(:, 2);
N = length(y);
X = [ones(N, 1) X];

% Racunanje i ispis koeficijenata modela
W = inv(X' * X) * X' * y;
disp('Model');
disp(W);

% Prikaz podataka i modela
plot(X(:, 2:end), y, 'rx', 'MarkerSize', 5);
hold on;
plot(X(:, 2), X*W, '-');
legend('Training data', 'Linear regression');
xlabel('x');
ylabel('y');
