Main Content

Polynomial Evaluation

Evaluate polynomial expression

  • Polynomial Evaluation block

Libraries:
DSP System Toolbox / Math Functions / Polynomial Functions

Description

The Polynomial Evaluation block applies a polynomial function to the real or complex input at the In port.

The equivalent MATLAB® code is shown here.

y = polyval(u)

The Polynomial Evaluation block performs this operation more efficiently than the equivalent construction using the Sum (Simulink) and Math Function (Simulink) blocks.

Examples

expand all

Open the ex_leastsquarespolyfit_ref model. The Polynomial Evaluation block uses this second-order polynomial to generate four values of dependent variable y from four values of independent variable u received at the In port.

The polynomial coefficients are supplied in the vector [-2 0 3] at the Coeffs port. Note that the coefficient of the first-order term is zero.

The Control points parameter of the Least Squares Polynomial Fit block is configured with the same four values of independent variable u that are used as input to the Polynomial Evaluation block, [1 2 3 4]. The Least Squares Polynomial Fit block uses these values together with the input values of dependent variable y to reconstruct the original polynomial coefficients.

Ports

Input

expand all

Specify the input data on which the block applies the polynomial function as a vector or a matrix.

Data Types: single | double
Complex Number Support: Yes

Specify a vector of coefficients in order of descending exponents. For more information on how the block operates for various coefficient vectors, see Constant coefficients.

Dependencies

To enable this port, clear the Use constant coefficients parameter.

Data Types: single | double
Complex Number Support: Yes

Output

expand all

The block applies the polynomial function on the input data and outputs a vector or a matrix of the same size and complexity as the input data.

Data Types: single | double
Complex Number Support: Yes

Parameters

expand all

When you select the Use constant coefficients parameter, you specify the polynomial expression in the Constant coefficients parameter. When you do not select the Use constant coefficients parameter, you specify a variable polynomial expression through the Coeffs port. In both cases, the polynomial is specified as a vector of real or complex coefficients in the order of descending exponents.

Specify the vector of polynomial coefficients to apply to the input in order of descending exponents.

This table shows how the block operates with different coefficient vectors.

Coefficient VectorEquivalent Polynomial Expression
[1 2 3 4 5]

y=u4+2u3+3u2+4u+5

[1 0 3 0 5]

y=u4+3u2+5

[1 2+i 3 4-3i 5i]

y=u4+(2+i)u3+3u2+(43i)u+5i

Dependencies

To enable this parameter, select the Use constant coefficients check box.

Complex Number Support: Yes

Block Characteristics

Data Types

double | single

Multidimensional Signals

No

Variable-Size Signals

No

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced before R2006a

See Also

Functions

Blocks