bivariatePolynomialEval

PURPOSE ^

BIVARIATEPOLYTERMS Get the terms of a bivariate polynomial function of a

SYNOPSIS ^

function eval = bivariatePolynomialEval(coeffs, x, y)

DESCRIPTION ^

BIVARIATEPOLYTERMS Get the terms of a bivariate polynomial function of a
 given degree

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function eval = bivariatePolynomialEval(coeffs, x, y)
0002 %BIVARIATEPOLYTERMS Get the terms of a bivariate polynomial function of a
0003 % given degree
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 numCoeffs = numel(coeffs);
0013 if numCoeffs == 0
0014     eval = zeros(size(x));
0015     return
0016 end
0017 
0018 % Infer the degree of the polynomial from the number of coefficients
0019 switch numCoeffs
0020     case 1 % Constant
0021         degree = 0;
0022     case 3 % Linear
0023         degree = 1;
0024     case 6 % Quadratic
0025         degree = 2;
0026     case 10 % Cubic
0027         degree = 3;
0028     otherwise
0029         error('Polynomial degree not implemented');
0030 end
0031 
0032 % Get the terms of this polynomial
0033 terms = bivariatePolynomialTerms(degree, x, y);
0034 
0035 % Evaluate using coefficients
0036 eval = terms*coeffs;
0037     
0038 end
0039

Generated on Thu 10-Dec-2020 17:34:27 by m2html © 2005