1function [theta] = normalEqn(X, y) 2%NORMALEQN Computes the closed-form solution to linear regression 3% NORMALEQN(X,y) computes the closed-form solution to linear 4% regression using the normal equations. 5 6theta = zeros(size(X, 2), 1); 7 8% ====================== YOUR CODE HERE ====================== 9% Instructions: Complete the code to compute the closed form solution 10% to linear regression and put the result in theta. 11% 12 13% ---------------------- Sample Solution ---------------------- 14theta = pinv(X'*X) * (X'*y); 15% ------------------------------------------------------------- 16 17 18% ============================================================ 19 20end 21 22