griddedInterpolant — Create an object that interpolates real dense data on a rectilinear grid.
griddedInterpolant constructs an interpolant object with GridVectors, Values, Method, and ExtrapolationMethod properties. Calling the object with parentheses evaluates the interpolant at query points.
Syntax
F = griddedInterpolant
F = griddedInterpolant(V)
F = griddedInterpolant(x, v)
F = griddedInterpolant(gridVecs, V)
F = griddedInterpolant(X1, X2, ..., Xn, V)
F = griddedInterpolant(___, Method)
F = griddedInterpolant(___, Method, ExtrapolationMethod)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
args | Any | Variadic | — | Grid vectors or full grids, values, interpolation method, and extrapolation method. |
Returns
| Name | Type | Description |
|---|---|---|
F | Any | Gridded interpolant object. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:griddedInterpolant:InvalidInput | Grid, value, method, or query inputs are invalid. | griddedInterpolant: invalid input |
RunMat:griddedInterpolant:UnsupportedMethod | The requested interpolation or extrapolation method is not implemented by RunMat. | griddedInterpolant: unsupported interpolation method |
RunMat:griddedInterpolant:Internal | Object construction, property access, or interpolation output construction fails. | griddedInterpolant: internal error |
How griddedInterpolant works
griddedInterpolant(V)uses default grid vectors1:size(V,dim).griddedInterpolant(x, v)andgriddedInterpolant({x1,...,xn}, V)use explicit compact grid vectors.- Full-grid construction with
griddedInterpolant(X1,...,Xn,V)extracts compact grid vectors from monotone full grids. - Evaluation supports
F(xq)for 1-D data,F(xq1,...,xqn)for matching-shape query arrays,F(Xq)for row-wise N-D query points, andF({xg1,...,xgn})for full query grids. - Linear, nearest, next, and previous methods are supported. PCHIP and spline methods are supported for 1-D grids. Cubic, makima, and N-D higher-order interpolation are reported as unsupported instead of approximated.
Examples
Linear interpolation from explicit sample points
F = griddedInterpolant([0 1 2], [0 10 40]);
yq = F([0.5 1.5])Expected output:
yq = [5 25]Two-dimensional interpolation from grid vectors
F = griddedInterpolant({[0 1], [0 2]}, [0 20; 10 30]);
yq = F(0.5, 1)Expected output:
yq = 15Using griddedInterpolant with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how griddedInterpolant changes the result.
Run a small griddedInterpolant example, explain the result, then change one input and compare the output.
Related Math functions
Elementwise
abs · angle · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · uint32
Trigonometry
acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh
Reduction
all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var
Structure
bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm
Signal
blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane
Optim
coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimset · quad · secondordercone
Ops
cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how griddedInterpolant is executed, line by line, in Rust.
- View the source for griddedInterpolant in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.