here i dont understand clearly the purpose of ones matrix ?? what is its use?
Non understanding of concepts
As you most remember, the equation of the line we are following is given by theta(transpose)*x. Here, the would be a theta(0) value which will represent the bias term for the equation of the line. The value of x which gets multiplied by this value of theta, i.e., x(0) must be 1. Thus, for this reason we add a ones row with shape equal to the number of examples.
I hope this clears your doubt.