vander

Vandermonde matrix whose columns are decreasing powers of the input vector.

Category: Mathematics > Elementary Math

Syntax

A = vander(v)

Returns the square Vandermonde matrix of the vector v.

Description

The last column is all ones, the one before it is v itself, and so on up to v.^(n-1) in the first column. A polynomial of degree n-1 that passes through the points (v(i), y(i)) has coefficients vander(v) \ y(:), which is how interpolating polynomials are defined.

Vandermonde matrices become very ill conditioned as n grows, so for fitting in practice polyfit is preferable.

Input arguments

v
Vector of n values.

Output arguments

A
Matrix of size n-by-n with A(i,j) = v(i)^(n-j).

Example

Interpolating polynomial

v = [1 2 3];
A = vander(v)
y = [2; 5; 10];
coef = round(A \ y).'
Output
A = 3×3

     1     1     1
     4     2     1
     9     3     1
coef = 1×3

     1     0     1

The coefficients of x^2 + 1: the polynomial passes through (1,2), (2,5) and (3,10).

See also

polyfit polyval toeplitz hankel cond