annotate doc/interpreter/interp.txi @ 17281:bc924baa2c4e

doc: Add new @qcode macro for code samples which are quoted. Macro handles options ("on") or properties ("position") more elegantly than @code{"text"}. * doc/interpreter/macros.texi: Add new @qcode macro. * doc/interpreter/tips.txi: Add documentation about @qcode macro. * doc/interpreter/basics.txi, doc/interpreter/container.txi, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/func.txi, doc/interpreter/grammar.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/io.txi, doc/interpreter/matrix.txi, doc/interpreter/numbers.txi, doc/interpreter/oop.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/quad.txi, doc/interpreter/sparse.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/vectorize.txi, libinterp/corefcn/balance.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/conv2.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/pager.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/syscalls.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/tril.cc, libinterp/corefcn/typecast.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-mat.cc, scripts/@ftp/ftp.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/shell_cmd.m, scripts/general/dblquad.m, scripts/general/display.m, scripts/general/genvarname.m, scripts/general/idivide.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/interpn.m, scripts/general/isa.m, scripts/general/profexplore.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/randi.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/triplequad.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/image/cmpermute.m, scripts/image/colormap.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/ind2gray.m, scripts/image/lines.m, scripts/image/rgb2ind.m, scripts/image/spinmap.m, scripts/io/dlmwrite.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/javaclasspath.m, scripts/java/usejava.m, scripts/miscellaneous/bzip2.m, scripts/miscellaneous/computer.m, scripts/miscellaneous/copyfile.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/license.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m, scripts/miscellaneous/parseparams.m, scripts/miscellaneous/unix.m, scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m, scripts/optimization/fminunc.m, scripts/optimization/fsolve.m, scripts/optimization/fzero.m, scripts/optimization/glpk.m, scripts/optimization/lsqnonneg.m, scripts/optimization/optimset.m, scripts/optimization/pqpnonneg.m, scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axis.m, scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/colorbar.m, scripts/plot/daspect.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m, scripts/plot/grid.m, scripts/plot/guihandles.m, scripts/plot/hdl2struct.m, scripts/plot/hidden.m, scripts/plot/hold.m, scripts/plot/isonormals.m, scripts/plot/isosurface.m, scripts/plot/legend.m, scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m, scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m, scripts/plot/patch.m, scripts/plot/pbaspect.m, scripts/plot/pcolor.m, scripts/plot/plot.m, scripts/plot/print.m, scripts/plot/private/__add_default_menu__.m, scripts/plot/quiver.m, scripts/plot/quiver3.m, scripts/plot/refreshdata.m, scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/shading.m, scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/stem.m, scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m, scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/uigetfile.m, scripts/plot/uimenu.m, scripts/plot/uiputfile.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m, scripts/plot/xlim.m, scripts/plot/ylim.m, scripts/plot/zlim.m, scripts/polynomial/conv.m, scripts/polynomial/polyout.m, scripts/polynomial/splinefit.m, scripts/set/ismember.m, scripts/set/powerset.m, scripts/set/setdiff.m, scripts/set/union.m, scripts/set/unique.m, scripts/signal/detrend.m, scripts/signal/filter2.m, scripts/signal/freqz.m, scripts/signal/periodogram.m, scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m, scripts/sparse/eigs.m, scripts/sparse/svds.m, scripts/specfun/legendre.m, scripts/special-matrix/gallery.m, scripts/statistics/base/mean.m, scripts/statistics/base/moment.m, scripts/statistics/tests/cor_test.m, scripts/statistics/tests/kolmogorov_smirnov_test.m, scripts/statistics/tests/kolmogorov_smirnov_test_2.m, scripts/statistics/tests/kruskal_wallis_test.m, scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/sign_test.m, scripts/statistics/tests/t_test.m, scripts/statistics/tests/t_test_2.m, scripts/statistics/tests/t_test_regression.m, scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m, scripts/statistics/tests/welch_test.m, scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m, scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m, scripts/strings/index.m, scripts/strings/isstrprop.m, scripts/strings/mat2str.m, scripts/strings/regexptranslate.m, scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjust.m, scripts/strings/strmatch.m, scripts/strings/validatestring.m, scripts/testfun/demo.m, scripts/testfun/example.m, scripts/testfun/test.m, scripts/time/addtodate.m, scripts/time/asctime.m, scripts/time/datestr.m, scripts/time/datetick.m, scripts/time/weekday.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use new @qcode macro.
author Rik <rik@octave.org>
date Mon, 19 Aug 2013 20:46:38 -0700
parents e7a059a9a644
children 1efe4c65c5cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1 @c Copyright (C) 2007-2012 John W. Eaton
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
2 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
3 @c This file is part of Octave.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
4 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
5 @c Octave is free software; you can redistribute it and/or modify it
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
6 @c under the terms of the GNU General Public License as published by the
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
7 @c Free Software Foundation; either version 3 of the License, or (at
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
8 @c your option) any later version.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
9 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
13 @c for more details.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
14 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
15 @c You should have received a copy of the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
16 @c along with Octave; see the file COPYING. If not, see
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6939
diff changeset
17 @c <http://www.gnu.org/licenses/>.
6549
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
18
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
19 @node Interpolation
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
20 @chapter Interpolation
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
21
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
22 @menu
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
23 * One-dimensional Interpolation::
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
24 * Multi-dimensional Interpolation::
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
25 @end menu
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
26
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
27 @node One-dimensional Interpolation
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
28 @section One-dimensional Interpolation
6549
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
29
6850
9398f6a81bdf [project @ 2007-08-31 17:29:22 by jwe]
jwe
parents: 6750
diff changeset
30 Octave supports several methods for one-dimensional interpolation, most
9398f6a81bdf [project @ 2007-08-31 17:29:22 by jwe]
jwe
parents: 6750
diff changeset
31 of which are described in this section. @ref{Polynomial Interpolation}
17097
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 14856
diff changeset
32 and @ref{Interpolation on Scattered Data} describe additional methods.
6850
9398f6a81bdf [project @ 2007-08-31 17:29:22 by jwe]
jwe
parents: 6750
diff changeset
33
6549
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
34 @DOCSTRING(interp1)
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
35
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
36 There are some important differences between the various interpolation
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
37 methods. The @qcode{"spline"} method enforces that both the first and second
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
38 derivatives of the interpolated values have a continuous derivative,
9070
e9dc2ed2ec0f Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
39 whereas the other methods do not. This means that the results of the
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
40 @qcode{"spline"} method are generally smoother. If the function to be
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
41 interpolated is in fact smooth, then @qcode{"spline"} will give excellent
9070
e9dc2ed2ec0f Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
42 results. However, if the function to be evaluated is in some manner
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
43 discontinuous, then @qcode{"pchip"} interpolation might give better results.
6743
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
44
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
45 This can be demonstrated by the code
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
46
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
47 @example
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
48 @group
6743
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
49 t = -2:2;
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
50 dt = 1;
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
51 ti =-2:0.025:2;
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
52 dti = 0.025;
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
53 y = sign (t);
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
54 ys = interp1 (t,y,ti,"spline");
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
55 yp = interp1 (t,y,ti,"pchip");
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
56 ddys = diff (diff (ys)./dti) ./ dti;
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
57 ddyp = diff (diff (yp)./dti) ./ dti;
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
58 figure (1);
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
59 plot (ti,ys,'r-', ti,yp,'g-');
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
60 legend ("spline", "pchip", 4);
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
61 figure (2);
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
62 plot (ti,ddys,'r+', ti,ddyp,'g*');
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
63 legend ("spline", "pchip");
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
64 @end group
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
65 @end example
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
66
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
67 @ifnotinfo
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
68 @noindent
6743
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
69 The result of which can be seen in @ref{fig:interpderiv1} and
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
70 @ref{fig:interpderiv2}.
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
71
6743
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
72 @float Figure,fig:interpderiv1
9088
77e71f3da3d6 Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents: 9070
diff changeset
73 @center @image{interpderiv1,4in}
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
74 @caption{Comparison of @qcode{"pchip"} and @qcode{"spline"} interpolation methods for a
6743
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
75 step function}
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
76 @end float
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
77
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
78 @float Figure,fig:interpderiv2
9088
77e71f3da3d6 Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents: 9070
diff changeset
79 @center @image{interpderiv2,4in}
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
80 @caption{Comparison of the second derivative of the @qcode{"pchip"} and @qcode{"spline"}
6743
f11fec9c06b0 [project @ 2007-06-18 19:12:48 by dbateman]
dbateman
parents: 6723
diff changeset
81 interpolation methods for a step function}
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
82 @end float
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
83 @end ifnotinfo
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
84
7984
bbaa5d7d0143 Some documentation updates
David Bateman <dbateman@free.fr>
parents: 7018
diff changeset
85 A simplified version of @code{interp1} that performs only linear
9070
e9dc2ed2ec0f Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
86 interpolation is available in @code{interp1q}. This argument is slightly
7984
bbaa5d7d0143 Some documentation updates
David Bateman <dbateman@free.fr>
parents: 7018
diff changeset
87 faster than @code{interp1} as to performs little error checking.
bbaa5d7d0143 Some documentation updates
David Bateman <dbateman@free.fr>
parents: 7018
diff changeset
88
bbaa5d7d0143 Some documentation updates
David Bateman <dbateman@free.fr>
parents: 7018
diff changeset
89 @DOCSTRING(interp1q)
bbaa5d7d0143 Some documentation updates
David Bateman <dbateman@free.fr>
parents: 7018
diff changeset
90
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
91 Fourier interpolation, is a resampling technique where a signal is
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
92 converted to the frequency domain, padded with zeros and then
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
93 reconverted to the time domain.
6549
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
94
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
95 @DOCSTRING(interpft)
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
96
9070
e9dc2ed2ec0f Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
97 There are two significant limitations on Fourier interpolation. Firstly,
8495
e7b4de25ecb6 [docs] non periodic => non-periodic
Brian Gough <bjg@gnu.org>
parents: 8347
diff changeset
98 the function signal is assumed to be periodic, and so non-periodic
9070
e9dc2ed2ec0f Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
99 signals will be poorly represented at the edges. Secondly, both the
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
100 signal and its interpolation are required to be sampled at equispaced
9070
e9dc2ed2ec0f Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
101 points. An example of the use of @code{interpft} is
6549
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
102
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
103 @example
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
104 @group
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
105 t = 0 : 0.3 : pi; dt = t(2)-t(1);
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
106 n = length (t); k = 100;
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
107 ti = t(1) + [0 : k-1]*dt*n/k;
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
108 y = sin (4*t + 0.3) .* cos (3*t - 0.1);
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
109 yp = sin (4*ti + 0.3) .* cos (3*ti - 0.1);
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
110 plot (ti, yp, "g", ti, interp1 (t, y, ti, "spline"), "b", ...
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
111 ti, interpft (y, k), "c", t, y, 'r+');
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
112 legend ('sin(4t+0.3)cos(3t-0.1', "spline", "interpft", "data");
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
113 @end group
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
114 @end example
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
115
8828
8463d1a2e544 Doc fixes.
Brian Gough <bjg@network-theory.co.uk>
parents: 8495
diff changeset
116 @noindent
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
117 @ifinfo
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 9367
diff changeset
118 which demonstrates the poor behavior of Fourier interpolation for non-periodic
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 9367
diff changeset
119 functions.
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
120 @end ifinfo
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
121 @ifnotinfo
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 9367
diff changeset
122 which demonstrates the poor behavior of Fourier interpolation for non-periodic
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 9367
diff changeset
123 functions, as can be seen in @ref{fig:interpft}.
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
124
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
125 @float Figure,fig:interpft
9088
77e71f3da3d6 Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents: 9070
diff changeset
126 @center @image{interpft,4in}
8495
e7b4de25ecb6 [docs] non periodic => non-periodic
Brian Gough <bjg@gnu.org>
parents: 8347
diff changeset
127 @caption{Comparison of @code{interp1} and @code{interpft} for non-periodic data}
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
128 @end float
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
129 @end ifnotinfo
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
130
17097
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 14856
diff changeset
131 In addition, the support functions @code{spline} and @code{lookup} that
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
132 underlie the @code{interp1} function can be called directly.
6549
5a5a09d7deb8 [project @ 2007-04-20 06:55:29 by jwe]
jwe
parents:
diff changeset
133
6558
e0e1c6df5ab2 [project @ 2007-04-20 19:33:24 by jwe]
jwe
parents: 6549
diff changeset
134 @DOCSTRING(spline)
e0e1c6df5ab2 [project @ 2007-04-20 19:33:24 by jwe]
jwe
parents: 6549
diff changeset
135
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
136 @node Multi-dimensional Interpolation
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
137 @section Multi-dimensional Interpolation
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
138
6939
46d1ad37d943 [project @ 2007-10-01 16:12:20 by jwe]
jwe
parents: 6850
diff changeset
139 There are three multi-dimensional interpolation functions in Octave, with
6850
9398f6a81bdf [project @ 2007-08-31 17:29:22 by jwe]
jwe
parents: 6750
diff changeset
140 similar capabilities. Methods using Delaunay tessellation are described
9398f6a81bdf [project @ 2007-08-31 17:29:22 by jwe]
jwe
parents: 6750
diff changeset
141 in @ref{Interpolation on Scattered Data}.
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
142
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
143 @DOCSTRING(interp2)
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
144
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
145 @DOCSTRING(interp3)
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
146
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
147 @DOCSTRING(interpn)
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
148
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
149 A significant difference between @code{interpn} and the other two
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 9367
diff changeset
150 multi-dimensional interpolation functions is the fashion in which the
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
151 dimensions are treated. For @code{interp2} and @code{interp3}, the y-axis is
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
152 considered to be the columns of the matrix, whereas the x-axis corresponds to
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
153 the rows of the array. As Octave indexes arrays in column major order, the
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
154 first dimension of any array is the columns, and so @code{interpn} effectively
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
155 reverses the 'x' and 'y' dimensions. Consider the example,
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
156
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
157 @example
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
158 @group
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
159 x = y = z = -1:1;
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
160 f = @@(x,y,z) x.^2 - y - z.^2;
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
161 [xx, yy, zz] = meshgrid (x, y, z);
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
162 v = f (xx,yy,zz);
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
163 xi = yi = zi = -1:0.1:1;
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
164 [xxi, yyi, zzi] = meshgrid (xi, yi, zi);
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
165 vi = interp3 (x, y, z, v, xxi, yyi, zzi, "spline");
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
166 [xxi, yyi, zzi] = ndgrid (xi, yi, zi);
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17097
diff changeset
167 vi2 = interpn (x, y, z, v, xxi, yyi, zzi, "spline");
6723
8bfb4ff637e1 [project @ 2007-06-14 10:16:35 by dbateman]
dbateman
parents: 6721
diff changeset
168 mesh (zi, yi, squeeze (vi2(1,:,:)));
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
169 @end group
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
170 @end example
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
171
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
172 @noindent
9070
e9dc2ed2ec0f Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
173 where @code{vi} and @code{vi2} are identical. The reversal of the
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
174 dimensions is treated in the @code{meshgrid} and @code{ndgrid} functions
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
175 respectively.
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
176 @ifnotinfo
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
177 The result of this code can be seen in @ref{fig:interpn}.
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
178
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
179 @float Figure,fig:interpn
9088
77e71f3da3d6 Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents: 9070
diff changeset
180 @center @image{interpn,4in}
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
181 @caption{Demonstration of the use of @code{interpn}}
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
182 @end float
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
183 @end ifnotinfo
6702
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
184
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
185 In additional the support function @code{bicubic} that underlies the
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
186 cubic interpolation of @code{interp2} function can be called directly.
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
187
b2391d403ed2 [project @ 2007-06-12 21:39:26 by dbateman]
dbateman
parents: 6558
diff changeset
188 @DOCSTRING(bicubic)