|
Contents | Previous | Next | Subchapters |
| Syntax |
interp(new_grid, old_table)
|
interp(new_grid, old_table, ind)
| |
| See Also | interp1 , interp2 , lagrange , cubespl |
Both the new and old grid of independent variables values
(both new_grid and the independent variable column of
old_table)
must be
strictly monotone increasing
.
interp function uses a linear approximation
between independent variable values in the old grid.
For instance, suppose you recorded the following temperature data:
| time | temperature |
| 1:00 | 65 |
| 2:00 | 68 |
| 3:00 | 72 |
| 4:00 | 73 |
| 5:00 | 73 |
old_table = { ...
[1., 65.], ...
[2., 68.], ...
[3., 72.], ...
[4., 73.], ...
[5., 73.] ...
}
new_grid = {1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5.}
interp(new_grid, old_table)
to which O-Matrix will respond
{
[ 1 , 65 ]
[ 1.5 , 66.5 ]
[ 2 , 68 ]
[ 2.5 , 70 ]
[ 3 , 72 ]
[ 3.5 , 72.5 ]
[ 4 , 73 ]
[ 4.5 , 73 ]
[ 5 , 73 ]
}
The first column in the matrix above is the time at half-hour intervals,
and the second column is the interpolated values for temperature.
The interp function will extrapolate the linear approximation
if an new grid value falls outside the range of old grid.
If you continue the previous example by entering
new_grid = {.5, 5.5}
interp(new_grid, old_table)
O-Matrix will respond
[ 0.5 , 63.5 ]
[ 5.5 , 73 ]
This approximates the temperature at 12:30 and 5:30,
both of which lie outside the range of the old grid
(the first column of table).