1function J = computeCost(X, y, theta) 2%COMPUTECOST Compute cost for linear regression 3% J = COMPUTECOST(X, y, theta) computes the cost of using theta as the 4% parameter for linear regression to fit the data points in X and y 5 6% Initialize some useful values 7m = length(y); % number of training examples 8 9% You need to return the following variables correctly 10J = 0; 11 12% ====================== YOUR CODE HERE ====================== 13% Instructions: Compute the cost of a particular choice of theta 14% You should set J to the cost. 15 16predictions = X * theta; 17sqrErrors = (predictions - y).^2; 18J = 1/(2*m) * sum(sqrErrors); 19%printf("The size of J is\n"); 20%disp(size(J)); 21% ========================================================================= 22 23end 24 25