%% Mixed Multi-Dimensional Basis Functions
% Create a set of two-dimensional basis functions where the expansion is quadratic in one variable and periodic in the other variable.
% First generate the one-dimensional expansions. Name the variables for improved readability.

F1 = polyBasis('canonical',2,'x');
F2 = fourierBasis(1,1,'y');

%
% For simplicity, this example takes only the first harmonic of the periodic variation. These expansions have basis functions given by:
% F1\left( x \right) = \left[ {x,{x^2}} \right],\quad F2\left( y \right)
% = \left[ {\cos \left( {\pi y} \right),\sin \left( {\pi y} \right)}
% \right].
% Create the two-dimensional basis function expansion. Note that ndBasis preserves the variable names you assigned to one-dimensional expansions.

F = ndBasis(F1,F2)

%
% The array returned by F includes all multiplicative combinations of the basis functions:
% F\left( {x,y} \right) = \left[ {x,{x^2},\cos \left( {\pi y}
% \right),\cos \left( {\pi y} \right)x,\cos \left( {\pi y}
% \right){x^2},\sin \left( {\pi y} \right),x\sin \left( {\pi y}
% \right),{x^2}\sin \left( {\pi y} \right)} \right].
% To confirm this, evaluate F for x = 0.2, y = -0.3.

F(0.2,-0.3)

% Copyright 2015 The MathWorks, Inc.