
%load the data
d = load('datafile');
%take x to be the first column of the data file
x = d(:,1);
%take y to be the second column of the data file
y = d(:,2);

%plot the data
figure;
plot(x,y,'*');
%fit a line and store the coefficients in p
p = polyfit(x,y,1);

