Are there any Matlab function or general code to generate all the combinations of features of a three-variable polynomial equation with a degree of n? For three variable of degree 3, the combinations of features will be 1, x, y, z, x^2, y^2, z^2, xy,yz,zx, x^3, y^3, z^3, x^2y, y^2z, z^2x, xyz.... and so on.
I already have the Matlab code for two variable and n degree from Andrew Ng's machine learning course.
function out = mapFeature(X1, X2)
degree = 6;
out = ones(size(X1(:,1)));
for i = 1:degree
for j = 0:i
out(:, end+1) = (X1.^(i-j)).*(X2.^j);
end
end
end
I was wondering if there is any code for three variable of n degree. Thanks in advance.