bernsteinMatrix

Matrix of Bernstein polynomial basis functions.

Category: Mathematics > Linear Algebra

Syntax

B = bernsteinMatrix(n, t)

Returns the n+1 Bernstein basis polynomials of degree n evaluated at t.

Description

The Bernstein polynomials are non-negative on [0, 1] and add up to 1, which makes them the weights of Bezier curves: a curve is B * P, where P lists the control points. With a symbolic t the result is a symbolic row vector.

Input arguments

n
Non-negative integer degree.
t
Symbolic variable or numeric vector of parameter values, typically in [0, 1].

Output arguments

B
Matrix with n+1 columns, one per basis polynomial b(k,n)(t) = nchoosek(n,k)*t^k*(1-t)^(n-k); one row per value of t.

Example

Degree 2 basis

syms t
bernsteinMatrix(2, t)
bernsteinMatrix(2, [0 0.5 1])
Output
ans = 
[(t - 1)^2, -2*t*(t - 1), t^2]
ans = 3×3

    1.0000         0         0
    0.2500    0.5000    0.2500
         0         0    1.0000

Notes

Symbolic output is written in factored form, for example (t - 1)^2 for (1 - t)^2.

See also

nchoosek polyfit interp1 poly2sym