warmUp
返回一个5阶单位矩阵
A = eye(5)
plotData
plot(x,y,'rx','MarkerSize',10)
ylabel('Profit in $10,000s')
xlabel('Population of City in 10,000s')
computeCost
h = x * theta
J = 0
for i = 1:m
J = J +(h(i) - y(i)) * (h(i) - y(i))
end
J = J / (2 * m)
gradientDescent
h = X * theta
sum = zeros(size(X,2),1)
for i = 1:m
sum = sum + (h(i) - y(i)).* X(i,:)'
endfor
theta = theta - alpha * sum / m