1.0.20 • Published 1 year ago
interp1 v1.0.20
interp1
MATLAB-inspired 1-dimensional data interpolation.
Importing this function
Node Modules
- Run
npm install interp1
- Add an import to the npm package
import interp1 from 'interp1';
- Then you can use the function in your code.
CDN
- Put the following script tag
<script src='https://cdn.jsdelivr.net/npm/interp1@1/dist/interp1.umd.min.js'></script>
in the head of your index.html - Then you can use the function in your code.
API
vqs = interp1(xs, vs, xqs);
vqs = interp1(xs, vs, xqs, method);
The function takes the following arguments:
xs
: Array of independent sample points. No value may occur more than once.vs
: Array of dependent values v(x) with length equal to xs.xqs
: Array of query points.method
: Method of interpolation:linear
,nearest
,next
orprevious
. Defaults tolinear
.
It returns an array of interpolated values vqs
, corresponding to the query values xqs
.
Example
var vqs = interp1(
[1, 2, 3],
[-4, 6, 3],
[1, 1.5, 2.5],
'linear',
);
console.log(vqs);
// expected output: Array [-4, 1, 4.5]
NPM scripts
npm install
: Install dependenciesnpm test
: Run test suitenpm start
: Runnpm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typings, create docsnpm run lint
: Lints code
Related project
exact-linspace is a MATLAB-inspired function to create linearly spaced values.
1.0.20
1 year ago
1.0.19
1 year ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
3 years ago
1.0.15
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago