Multi-dimensional polynomial evaluation

Version 1.0.0.0 (2.73 KB) by Yi Sui
Multi-dimensional polynomial evaluation
511 Downloads
Updated 29 Oct 2013

View License

POLY_ND(order,x,y,z,...) returns the polynomial terms of N variables.
The input can be column vectors of numbers, chars, or symbols.
The terms are orgnized in ascending dimensions.i.e x then x,y then x,y,z.
EXAMPLE 1
syms x,y,z,t
poly_nd(4,x,y)
ans =
[ 1, x, x^2, x^3, x^4, y, x*y, x^2*y, x^3*y, y^2, x*y^2, x^2*y^2, y^3, x*y^3, y^4]

poly_nd(2,x,y,z)
ans =
[ 1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2]

poly_nd(2,x,y,z,t)
ans =
[ 1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2, t, t*x, t*y, t*z, t^2]

EXAMPLE 2
x=[0 1 2]'; %numbers vector
y=['y1'; 'y2'; 'y3']; % chars vector
z=sym('z',[1,3]); %symbols vector
poly_nd(2,x,y,z)
ans =
[ 1, 0, 0, y1, 0, y1^2, z1, 0, y1*z1, z1^2]
[ 1, 1, 1, y2, y2, y2^2, z2, z2, y2*z2, z2^2]
[ 1, 2, 4, y3, 2*y3, y3^2, z3, 2*z3, y3*z3, z3^2]

POLYVAL_ND(p,order,x,y,z,...) returns the value of ND polynomial p evaluated at point (x,y,z,...)

e.g for a 3D 2rd order polynomial:
coef: p = [p000 p100 p200 p010 p110 p020 p001 p101 p011 p002 ];
value: v = [ 1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2] *p'
p is orgnized in ascending dimension.i.e x then x,y then x,y

Cite As

Yi Sui (2024). Multi-dimensional polynomial evaluation (https://www.mathworks.com/matlabcentral/fileexchange/44098-multi-dimensional-polynomial-evaluation), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0