Most methods of the class sympoly are implemented such that they handle both scalar and array inputs. Since sympoly is a new-style class declared with the classdef keyword, you can use inheritance to derive custom classes from sympoly. when variables are strings, they are sorted alphabetically. The items in Variables are always sorted in a standard order, e.g. % create a system equation for a polynomial dynamic systemįurther examples are included in the subfolder "demo" in the distribution, reproduced with minor changes from the "Symbolic Polynomial Manipulation" package by John D'Errico.įrom an implementation point of view, a scalar sympoly object is a class with read-only properties ConstantValue, Variables, Coefficients and Exponents, where ConstantValue is a numeric scalar, Variables is a 1-by-n row cell vector of strings or a row vector of (subclasses of) symvariable objects, Coefficients is an m-by-1 numeric column vector of polynomial term coefficients, and Exponents is an m-by-n numeric matrix of exponents for each variable in each term. % create symbolic polynomials with variables other than strings % create a matrix of symbolic polynomials and take sum of rows % combine sympoly objects in arbitrary expressions In order to get a list of operations supported on a sympoly object, type "methods sympoly" at the command prompt.
#Matlab symbolic toolbox polynomial code#
a variable gradient coefficient extraction conversion from and to a Symbolic Toolbox sym object and a numeric array pretty-printing (overloaded disp and display functions) LaTeX and MatLab code generation (a character string that can be passed to eval).
Sympoly supports regular elementwise and matrix operations like addition, subtraction, multiplication, power and division transpose and diagonalization indefinite and definite integration and differentiation w.r.t. Where the summation is over i, the product over j, and c_i is the set of polynomial term coefficients, x_ij is a set of symbolic variables, p_ij is the (usually positive integer) exponent of each variable in a term where at least one p_ij is nonzero for a given i, and k is the constant term. A general multivariate polynomial is captured with the syntax A polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients.