Programmer Guide/Command Reference/EVAL/interp: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| (10 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}} | ||
;Usage 1:<code>interp(<var>x</var>, <var>n</var>, <var>type</var> {, <var>mv</var>})</code> | |||
;Usage:<code>interp(<var>x</var>, <var>n</var>, <var>type</var> {, <var>mv</var>})</code> | :Create an interpolated copy of the vector <var>x</var> with length <var>n</var>. | ||
:;<var>x</var> | :;<var>x</var>:vector to be interpolated, <var>x[i] = f(i)</var> | ||
:;<var>n</var> | :;<var>n</var>:length of the interpolated output vector; the interpolated vector can be shorter or longer than the original | ||
:;<var>type</var>:the type of interpolation to perform | :;<var>type</var>:the type of interpolation to perform | ||
:;<var>mv</var>:the value to use for 'missing values'. If mv is given, then interpolation is stopped when <code>''x''[i] = ''mv''</code>. This means that the sections without missing values are individually interpolated. If ''mv'' is not supplied, the whole vector ''x'' is interpolated. | ::''type''='''0''': linear interpolation | ||
::''type''='''1''': cubic spline interpolation | |||
:;<var>mv</var>:the value to use for ''missing values''. If ''mv'' is given, then interpolation is stopped when <code>''x''[i] = ''mv''</code>. This means that the sections without missing values are individually interpolated. If ''mv'' is not supplied, the whole vector ''x'' is interpolated. | |||
::'''note''': The missing value handling is implemented only for linear interpolation (''type''='''0''') | |||
;Result:The interpolated vector ''y'' with length ''n''. | ;Result:The interpolated vector ''y'' with length ''n''. | ||
;Usage 2:<code>interp(<var>x</var>, <var>y</var>, <var>xp</var> {, <var>type=1</var>})</code> | |||
:Get interpolated values of function <var>y=f(x)</var> at the position(s) <var>xp</var>. | |||
:;<var>x</var>:x value vector | |||
:;<var>y</var>:y value vector, ''y[i]'' = f(''x[i]'') | |||
:;<var>xp</var>:position(s) for interpolation (number, vector or matrix) | |||
:;<var>type</var>:the type of interpolation to perform | |||
::''type''='''0''': linear interpolation | |||
::''type''='''1''': cubic spline interpolation | |||
;Result:The interpolated values ''yp'' (same type as ''xp''). | |||
;See also: [[../rpolyreg|rpolyreg]], [[../qinterp|qinterp]], [[../map2map|map2map]] | |||
[[../#Functions|<function list>]] | |||
Latest revision as of 15:22, 28 October 2025
- Usage 1
interp(x, n, type {, mv})- Create an interpolated copy of the vector x with length n.
- x
- vector to be interpolated, x[i] = f(i)
- n
- length of the interpolated output vector; the interpolated vector can be shorter or longer than the original
- type
- the type of interpolation to perform
- type=0: linear interpolation
- type=1: cubic spline interpolation
- mv
- the value to use for missing values. If mv is given, then interpolation is stopped when
x[i] = mv. This means that the sections without missing values are individually interpolated. If mv is not supplied, the whole vector x is interpolated. - note: The missing value handling is implemented only for linear interpolation (type=0)
- Result
- The interpolated vector y with length n.
- Usage 2
interp(x, y, xp {, type=1})- Get interpolated values of function y=f(x) at the position(s) xp.
- x
- x value vector
- y
- y value vector, y[i] = f(x[i])
- xp
- position(s) for interpolation (number, vector or matrix)
- type
- the type of interpolation to perform
- type=0: linear interpolation
- type=1: cubic spline interpolation