% Solution to Section 2 exercise.

load salesdata

s = S(:,2);
M = [S(:,3),S(:,4),ones(416,1)];
x = M\s;

plot3(S(:,3),S(:,4),S(:,2),'o');
hold on
i=1:25;j=1:150;[I,J]=meshgrid(i,j);
z = x(1)*I+x(2)*J+x(3)*ones(150,25);
surf(I,J,z)
shading interp

P =10+5*randn(5,1);
I = 50+10*randn(5,1);
newdata=[P,I,ones(5,1)];
newsales=newdata*x

condition_number = cond(M)