## Name

plq_eval — Piecewise linear quadratic (plq), evaluate a plq function on a grid

## Calling Sequence

    [y, k] = plq_eval(plqf,X)

## Parameters

plqf

  matrix. A plq function with dimensions n x 4.

X

  column vector. A grid of points on which the function is sampled.

y

  column vector. A grid of points on which the plq function is evaluated on.

k

  matrix. A 3 x n matrix with information about which pieces of the plq function contained which X points.

## Description

<listitem>

Evaluates a plq function on a grid. This function is necessary as it allows the plq functions to be simplified into more manageable data with scilab functions such as plotting.

k is a matrix shaped like the following, with a column for each unique piece of the plq function an X value was in. For the i'th unique piece, the values X(L(i):R(i)) were evaluated using the I(i)'th row of the plq function.

            [I(0)    I(1)    ...     I(n-1)  I(n) ]
            [L(0)    L(1)    ...     L(n-1)  L(n) ]
            [R(0)    R(1)    ...     R(n-1)  R(n) ]

</listitem>

## Examples

    //Example 1
    X=[1;2;4;5;7;8;9];
    plqf=[3,0.5,0,0;6,0,0,0;%inf,0,1,0];
    [y,k] = plq_eval(plqf,X);

    //Example 2
    x=linspace(0,4)';
    plqf = build_plq(x,exp,exp);
    y=plq_eval(plqf,x);

## See Also

plq_function

## Authors

`Yves Lucet`, University of British Columbia, BC, Canada