File Exchange

image thumbnail

Multi-dimensional polynomial evaluation

version 1.0 (2.73 KB) by

Multi-dimensional polynomial evaluation



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.
syms x,y,z,t
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]

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

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]

x=[0 1 2]'; %numbers vector
y=['y1'; 'y2'; 'y3']; % chars vector
z=sym('z',[1,3]); %symbols vector
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

Comments and Ratings (0)

MATLAB Release
MATLAB 8.1 (R2013a)
Tags Add Tags

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video