A simple Octave/Matlab code to compute cost function for linear regression.
The computeCost.m file computes the cost function.
The gradientDescent.m file minimizes the cost cost function J(theta).
examples.txt has comma seperated variables, the first column is the independent variable x and the second column is the dependent variable y.