1function out = mapFeature(X1, X2) 2% MAPFEATURE Feature mapping function to polynomial features 3% 4% MAPFEATURE(X1, X2) maps the two input features 5% to quadratic features used in the regularization exercise. 6% 7% Returns a new feature array with more features, comprising of 8% X1, X2, X1.^2, X2.^2, X1*X2, X1*X2.^2, etc.. 9% 10% Inputs X1, X2 must be the same size 11% 12 13degree = 6; 14out = ones(size(X1(:,1))); 15for i = 1:degree 16 for j = 0:i 17 out(:, end+1) = (X1.^(i-j)).*(X2.^j); 18 end 19end 20 21end 22