| Spline Toolbox | Search  Help Desk |
| sorted | Examples |
Locate points with respect to meshpoints
Syntax
index = sorted(meshpoints,points)
Description
Various M-files in this toolbox need to determine the index j for which a given x lies in the interval [tj..tj+1], with (ti) a given nondecreasing sequence, e.g., a knot sequence. This job is done by sorted in the following fashion.
The vector index=sorted(meshpoints,points) is the integer sequence for which, for all j, index(j) equals the number of entries in meshpoints that are
spoints(j), with spoints=sort(points). Thus, if both meshpoints and points are nondecreasing, then
with obvious interpretations whenmeshpoints(index(j))![]()
points(j)<meshpoints(index(j)+1)
index(j)< 1 orlength(meshpoints)<index(j)+ 1
Examples
The statementsorted([1 1 1 2 2 3 3 3],[0:4])will generate the output
0 3 5 8 8, as will the statement
sorted([3 2 1 1 3 2 3 1],[2 3 0 4 1])
Algorithm
The indexing output fromsort([meshpoints(:).',points(:).']) is used.