1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="interp2d" xml:lang="en">
4 <refname>interp2d</refname>
5 <refpurpose>bicubic spline (2d) evaluation function</refpurpose>
8 <title>Calling Sequence</title>
9 <synopsis>[zp[, dzpdx, dzpdy[, d2zpdxx, d2zpdxy, d2zpdyy]]]=interp2d(xp, yp, x, y, C [,out_mode])</synopsis>
12 <title>Arguments</title>
18 a mx-by-my matrix of doubles, the <varname>x</varname> coordinates of the points where the spline is to be evaluated.
26 a mx-by-my matrix of doubles, the <varname>y</varname> coordinates of the points where the spline is to be evaluated.
34 a 1-by-nx matrix of doubles, the <varname>x</varname> coordinate of the interpolation points.
35 We must have x(i)<x(i+1), for i=1,2,...,nx-1.
44 a 1-by-ny matrix of doubles, the <varname>y</varname> coordinate of the interpolation points.
45 We must have y(i)<y(i+1), for i=1,2,...,ny-1.
54 The coefficients of the bicubic spline. The input argument of the interp2d function is the output argument of the <link linkend="splin2d">splin2d</link> function.
61 <para>a 1-by-1 matrix of strings, the evaluation of s outside the range [x(1),x(nx)] by [y(1),y(ny)].
69 a mx-by-my matrix of doubles, the evaluation of the <varname>z</varname> coordinate of the spline, i.e. zp(i,j)=s(xp(i,j),yp(i,j)), for i=1,2,...,mx and j = 1,2,...,my.
77 <para>a mx-by-my matrix of doubles, the first derivative of the spline with
78 respect to <varname>x</varname>.
86 <para>a mx-by-my matrix of doubles, the first derivative of the spline with
87 respect to <varname>y</varname>.
95 <para>a mx-by-my matrix of doubles, the second derivative of the spline with
96 respect to <varname>x</varname>.
104 <para> a mx-by-my matrix of doubles, the second derivative of the spline with
105 respect to <varname>x</varname> and <varname>y</varname>.
114 <para>a mx-by-my matrix of doubles, the second derivative of the spline with
115 respect to <varname>y</varname>.
122 <title>Description</title>
124 Given three vectors <literal>(x,y,C)</literal> defining a bicubic
125 spline or sub-spline function (see <link linkend="splin2d">splin2d</link>)
126 this function evaluates <emphasis>s</emphasis> (and <emphasis>ds/dx,
127 ds/dy, d2s/dxx, d2s/dxy, d2s/dyy
130 <emphasis>(xp(i),yp(i))</emphasis> :
135 <imagedata fileref="../mml/interp2_equation_1.mml"/>
140 The <literal>out_mode</literal> parameter defines the evaluation
141 rule for extrapolation, i.e. for <emphasis>(xp(i),yp(i)) not in
142 [x(1),x(nx)]x[y(1),y(ny)]
148 <term>"by_zero"</term>
150 <para>an extrapolation by zero is done</para>
154 <term>"by_nan"</term>
156 <para>extrapolation by Nan</para>
162 <para>the extrapolation is defined as follows :</para>
163 <programlisting role=""><![CDATA[
164 s(x,y) = s(proj(x,y)) where proj(x,y) is nearest point
165 of [x(1),x(nx)]x[y(1),y(ny)] from (x,y)
170 <term>"natural"</term>
172 <para>the extrapolation is done by using the nearest bicubic-patch
178 <term>"periodic"</term>
181 <literal>s</literal> is extended by periodicity.
188 <title>Examples</title>
190 <programlisting role="example"><![CDATA[
191 n = 7; // a n x n interpolation grid
192 x = linspace(0,2*%pi,n); y = x;
194 C = splin2d(x, y, z, "periodic");
196 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
197 m = 80; // discretisation parameter of the evaluation grid
198 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
199 [XX,YY] = ndgrid(xx,yy);
200 zz1 = interp2d(XX,YY, x, y, C, "C0");
201 plot3d(xx, yy, zz1, flag=[2 6 4])
202 xtitle("extrapolation with the C0 outmode")
205 n = 7; // a n x n interpolation grid
206 x = linspace(0,2*%pi,n); y = x;
208 C = splin2d(x, y, z, "periodic");
210 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
211 m = 80; // discretisation parameter of the evaluation grid
212 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
213 [XX,YY] = ndgrid(xx,yy);
214 zz1 = interp2d(XX,YY, x, y, C, "C0");
215 plot3d(xx, yy, zz1, flag=[2 6 4])
216 xtitle("extrapolation with the C0 outmode")
219 <programlisting role="example"><![CDATA[
220 n = 7; // a n x n interpolation grid
221 x = linspace(0,2*%pi,n); y = x;
223 C = splin2d(x, y, z, "periodic");
225 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
226 m = 80; // discretisation parameter of the evaluation grid
227 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
228 [XX,YY] = ndgrid(xx,yy);
229 zz2 = interp2d(XX,YY, x, y, C, "by_zero");
230 plot3d(xx, yy, zz2, flag=[2 6 4])
231 xtitle("extrapolation with the by_zero outmode")
234 n = 7; // a n x n interpolation grid
235 x = linspace(0,2*%pi,n); y = x;
237 C = splin2d(x, y, z, "periodic");
239 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
240 m = 80; // discretisation parameter of the evaluation grid
241 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
242 [XX,YY] = ndgrid(xx,yy);
243 zz2 = interp2d(XX,YY, x, y, C, "by_zero");
244 plot3d(xx, yy, zz2, flag=[2 6 4])
245 xtitle("extrapolation with the by_zero outmode")
247 <programlisting role="example"><![CDATA[
248 n = 7; // a n x n interpolation grid
249 x = linspace(0,2*%pi,n); y = x;
251 C = splin2d(x, y, z, "periodic");
253 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
254 m = 80; // discretisation parameter of the evaluation grid
255 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
256 [XX,YY] = ndgrid(xx,yy);
257 zz3 = interp2d(XX,YY, x, y, C, "periodic");
258 plot3d(xx, yy, zz3, flag=[2 6 4])
259 xtitle("extrapolation with the periodic outmode")
262 n = 7; // a n x n interpolation grid
263 x = linspace(0,2*%pi,n); y = x;
265 C = splin2d(x, y, z, "periodic");
267 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
268 m = 80; // discretisation parameter of the evaluation grid
269 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
270 [XX,YY] = ndgrid(xx,yy);
271 zz3 = interp2d(XX,YY, x, y, C, "periodic");
272 plot3d(xx, yy, zz3, flag=[2 6 4])
273 xtitle("extrapolation with the periodic outmode")
276 <programlisting role="example"><![CDATA[
277 n = 7; // a n x n interpolation grid
278 x = linspace(0,2*%pi,n); y = x;
280 C = splin2d(x, y, z, "periodic");
282 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
283 m = 80; // discretisation parameter of the evaluation grid
284 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
285 [XX,YY] = ndgrid(xx,yy);
286 zz4 = interp2d(XX,YY, x, y, C, "natural");
287 plot3d(xx, yy, zz4, flag=[2 6 4])
288 xtitle("extrapolation with the natural outmode")
292 n = 7; // a n x n interpolation grid
293 x = linspace(0,2*%pi,n); y = x;
295 C = splin2d(x, y, z, "periodic");
297 // now evaluate on a bigger domain than [0,2pi]x [0,2pi]
298 m = 80; // discretisation parameter of the evaluation grid
299 xx = linspace(-0.5*%pi,2.5*%pi,m); yy = xx;
300 [XX,YY] = ndgrid(xx,yy);
301 zz4 = interp2d(XX,YY, x, y, C, "natural");
302 plot3d(xx, yy, zz4, flag=[2 6 4])
303 xtitle("extrapolation with the natural outmode")
306 <refsection role="see also">
307 <title>See Also</title>
308 <simplelist type="inline">
310 <link linkend="splin2d">splin2d</link>
315 <title>History</title>
318 <revnumber>5.4.0</revnumber>
319 <revremark>Previously, imaginary part of input arguments were implicitly ignored.</revremark>