0001 function terms = bivariatePolynomialTerms(degree, x, y)
0002
0003
0004
0005 if size(x, 2) ~= 1
0006 error('X and Y must be column vectors');
0007 end
0008 if size(x) ~= size(y)
0009 error('Sizes of ''x'' and ''y'' must be the same');
0010 end
0011
0012 switch degree
0013 case 0
0014 terms = ones(size(x));
0015 case 1
0016 terms = [x y ones(size(x))];
0017 case 2
0018 terms = [x.*x, y.*y, x.*y, x, y, ones(size(x))];
0019 case 3
0020 terms = [x.*x.*x, y.*y.*y, x.*x.*y, x.*y.*y, x.*x, y.*y, x.*y, x, y, ones(size(x))];
0021 otherwise
0022
0023 terms = [];
0024 end
0025
0026
0027
0028 end
0029