annotate scripts/general/interp1.m @ 19631:db92e7e28e1f

strip trailing whitespace from most source files * NEWS, doc/interpreter/contributors.in, doc/interpreter/func.txi, doc/interpreter/genpropdoc.m, doc/interpreter/octave_logo.eps, doc/interpreter/plot.txi, doc/interpreter/stmt.txi, examples/data/Makefile.am, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/load-path.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/strfind.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/variables.cc, libinterp/octave-value/ov-classdef.cc, libinterp/octave-value/ov-classdef.h, libinterp/octave.cc, libinterp/parse-tree/lex.h, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/pt-classdef.h, liboctave/system/file-ops.cc, liboctave/system/oct-env.cc, m4/acinclude.m4, scripts/deprecated/finite.m, scripts/deprecated/fmod.m, scripts/deprecated/fnmatch.m, scripts/deprecated/luinc.m, scripts/deprecated/octave_tmp_file_name.m, scripts/deprecated/syl.m, scripts/deprecated/usage.m, scripts/general/inputParser.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/isequal.m, scripts/general/private/__isequal__.m, scripts/geometry/voronoi.m, scripts/image/image.m, scripts/image/imshow.m, scripts/image/ind2rgb.m, scripts/linear-algebra/bandwidth.m, scripts/linear-algebra/isbanded.m, scripts/miscellaneous/bzip2.m, scripts/miscellaneous/cast.m, scripts/miscellaneous/copyfile.m, scripts/miscellaneous/delete.m, scripts/miscellaneous/fullfile.m, scripts/miscellaneous/getappdata.m, scripts/miscellaneous/gunzip.m, scripts/miscellaneous/isappdata.m, scripts/miscellaneous/ls.m, scripts/miscellaneous/mex.m, scripts/miscellaneous/movefile.m, scripts/miscellaneous/orderfields.m, scripts/miscellaneous/recycle.m, scripts/miscellaneous/rmappdata.m, scripts/miscellaneous/setfield.m, scripts/miscellaneous/symvar.m, scripts/miscellaneous/tar.m, scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m, scripts/miscellaneous/ver.m, scripts/miscellaneous/what.m, scripts/miscellaneous/xor.m, scripts/miscellaneous/zip.m, scripts/optimization/fminbnd.m, scripts/optimization/sqp.m, scripts/path/private/getsavepath.m, scripts/path/savepath.m, scripts/pkg/pkg.m, scripts/pkg/private/installed_packages.m, scripts/plot/draw/plotyy.m, scripts/plot/draw/polar.m, scripts/plot/draw/private/__quiver__.m, scripts/plot/draw/private/__scatter__.m, scripts/plot/draw/private/__stem__.m, scripts/plot/draw/surface.m, scripts/plot/draw/surfnorm.m, scripts/plot/util/copyobj.m, scripts/plot/util/hgload.m, scripts/plot/util/hgsave.m, scripts/plot/util/isprop.m, scripts/plot/util/linkprop.m, scripts/plot/util/private/__go_draw_axes__.m, scripts/set/setdiff.m, scripts/set/union.m, scripts/signal/periodogram.m, scripts/sparse/eigs.m, scripts/sparse/ilu.m, scripts/sparse/qmr.m, scripts/sparse/sprand.m, scripts/sparse/sprandn.m, scripts/specfun/beta.m, scripts/specfun/ellipke.m, scripts/specfun/isprime.m, scripts/statistics/base/lscov.m, scripts/testfun/__run_test_suite__.m, scripts/testfun/test.m: Strip trailing whitespace.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 10:29:54 -0500
parents 0e1f5a750d00
children 4197fc428c7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
1 ## Copyright (C) 2014 Nir Krakauer
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17307
diff changeset
2 ## Copyright (C) 2000-2013 Paul Kienzle
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
3 ## Copyright (C) 2009 VZLU Prague
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
4 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
5 ## This file is part of Octave.
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
6 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
7 ## Octave is free software; you can redistribute it and/or modify it
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
8 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
9 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 ## your option) any later version.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
11 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
12 ## Octave is distributed in the hope that it will be useful, but
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
15 ## General Public License for more details.
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
16 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
17 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
18 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
19 ## <http://www.gnu.org/licenses/>.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
20
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
21 ## -*- texinfo -*-
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
22 ## @deftypefn {Function File} {@var{yi} =} interp1 (@var{x}, @var{y}, @var{xi})
10820
c44c786f87ba interp1.m: When absent set X equal to the inices of Y.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
23 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@var{y}, @var{xi})
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
24 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{method})
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
25 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{extrap})
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
26 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, "left")
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
27 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, "right")
14359
7277fe922e99 doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents: 14335
diff changeset
28 ## @deftypefnx {Function File} {@var{pp} =} interp1 (@dots{}, "pp")
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
29 ##
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
30 ## One-dimensional interpolation.
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
31 ##
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
32 ## Interpolate input data to determine the value of @var{yi} at the points
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
33 ## @var{xi}. If not specified, @var{x} is taken to be the indices of @var{y}
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
34 ## (@code{1:length (@var{y})}). If @var{y} is a matrix or an N-dimensional
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
35 ## array, the interpolation is performed on each column of @var{y}.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
36 ##
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
37 ## The interpolation @var{method} is one of:
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
38 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
39 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
40 ## @item @qcode{"nearest"}
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
41 ## Return the nearest neighbor.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10820
diff changeset
42 ##
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
43 ## @item @qcode{"previous"}
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
44 ## Return the previous neighbor.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10820
diff changeset
45 ##
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
46 ## @item @qcode{"next"}
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
47 ## Return the next neighbor.
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
48 ##
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
49 ## @item @qcode{"linear"} (default)
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
50 ## Linear interpolation from nearest neighbors.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10820
diff changeset
51 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
52 ## @item @qcode{"pchip"}
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
53 ## Piecewise cubic Hermite interpolating polynomial---shape-preserving
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
54 ## interpolation with smooth first derivative.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10820
diff changeset
55 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
56 ## @item @qcode{"cubic"}
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
57 ## Cubic interpolation (same as @qcode{"pchip"}).
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10820
diff changeset
58 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
59 ## @item @qcode{"spline"}
12175
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
60 ## Cubic spline interpolation---smooth first and second derivatives
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
61 ## throughout the curve.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
62 ## @end table
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
63 ##
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
64 ## Adding '*' to the start of any method above forces @code{interp1}
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
65 ## to assume that @var{x} is uniformly spaced, and only @code{@var{x}(1)}
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
66 ## and @code{@var{x}(2)} are referenced. This is usually faster,
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
67 ## and is never slower. The default method is @qcode{"linear"}.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
68 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
69 ## If @var{extrap} is the string @qcode{"extrap"}, then extrapolate values
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
70 ## beyond the endpoints using the current @var{method}. If @var{extrap} is a
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
71 ## number, then replace values beyond the endpoints with that number. When
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
72 ## unspecified, @var{extrap} defaults to @code{NA}.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
73 ##
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
74 ## If the string argument @qcode{"pp"} is specified, then @var{xi} should not
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19417
diff changeset
75 ## be supplied and @code{interp1} returns a piecewise polynomial object. This
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
76 ## object can later be used with @code{ppval} to evaluate the interpolation.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
77 ## There is an equivalence, such that @code{ppval (interp1 (@var{x},
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
78 ## @var{y}, @var{method}, @qcode{"pp"}), @var{xi}) == interp1 (@var{x}, @var{y},
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
79 ## @var{xi}, @var{method}, @qcode{"extrap"})}.
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
80 ##
10711
fbd7843974fa Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
81 ## Duplicate points in @var{x} specify a discontinuous interpolant. There
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
82 ## may be at most 2 consecutive points with the same value.
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
83 ## If @var{x} is increasing, the default discontinuous interpolant is
16816
12005245b645 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 15468
diff changeset
84 ## right-continuous. If @var{x} is decreasing, the default discontinuous
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
85 ## interpolant is left-continuous.
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
86 ## The continuity condition of the interpolant may be specified by using
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
87 ## the options @qcode{"left"} or @qcode{"right"} to select a left-continuous
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
88 ## or right-continuous interpolant, respectively.
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
89 ## Discontinuous interpolation is only allowed for @qcode{"nearest"} and
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
90 ## @qcode{"linear"} methods; in all other cases, the @var{x}-values must be
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17174
diff changeset
91 ## unique.
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
92 ##
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
93 ## An example of the use of @code{interp1} is
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
94 ##
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
95 ## @example
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
96 ## @group
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7671
diff changeset
97 ## xf = [0:0.05:10];
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7671
diff changeset
98 ## yf = sin (2*pi*xf/5);
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7671
diff changeset
99 ## xp = [0:10];
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7671
diff changeset
100 ## yp = sin (2*pi*xp/5);
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7671
diff changeset
101 ## lin = interp1 (xp, yp, xf);
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
102 ## near = interp1 (xp, yp, xf, "nearest");
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
103 ## pch = interp1 (xp, yp, xf, "pchip");
8507
cadc73247d65 style fixes
John W. Eaton <jwe@octave.org>
parents: 7671
diff changeset
104 ## spl = interp1 (xp, yp, xf, "spline");
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
105 ## plot (xf,yf,"r", xf,near,"g", xf,lin,"b", xf,pch,"c", xf,spl,"m",
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
106 ## xp,yp,"r*");
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
107 ## legend ("original", "nearest", "linear", "pchip", "spline");
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
108 ## @end group
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
109 ## @end example
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
110 ##
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
111 ## @seealso{pchip, spline, interpft, interp2, interp3, interpn}
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
112 ## @end deftypefn
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
113
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
114 ## Author: Paul Kienzle
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
115 ## Date: 2000-03-25
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
116 ## added 'nearest' as suggested by Kai Habel
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
117 ## 2000-07-17 Paul Kienzle
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
118 ## added '*' methods and matrix y
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
119 ## check for proper table lengths
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
120 ## 2002-01-23 Paul Kienzle
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
121 ## fixed extrapolation
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
122
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
123 function yi = interp1 (x, y, varargin)
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
124
10820
c44c786f87ba interp1.m: When absent set X equal to the inices of Y.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
125 if (nargin < 2 || nargin > 6)
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
126 print_usage ();
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
127 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
128
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
129 method = "linear";
6742
ebf96cc00ee9 [project @ 2007-06-18 16:27:52 by jwe]
jwe
parents: 6721
diff changeset
130 extrap = NA;
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
131 xi = [];
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12459
diff changeset
132 ispp = false;
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
133 firstnumeric = true;
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
134 rightcontinuous = NaN;
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
135
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
136 if (nargin > 2)
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
137 for i = 1:length (varargin)
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
138 arg = varargin{i};
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
139 if (ischar (arg))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9929
diff changeset
140 arg = tolower (arg);
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
141 switch (arg)
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
142 case "extrap"
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
143 extrap = "extrap";
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
144 case "pp"
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
145 ispp = true;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
146 case {"right", "-right"}
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
147 rightcontinuous = true;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
148 case {"left", "-left"}
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
149 rightcontinuous = false;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
150 otherwise
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
151 method = arg;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
152 endswitch
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
153 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9929
diff changeset
154 if (firstnumeric)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9929
diff changeset
155 xi = arg;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9929
diff changeset
156 firstnumeric = false;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9929
diff changeset
157 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9929
diff changeset
158 extrap = arg;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9929
diff changeset
159 endif
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
160 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
161 endfor
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
162 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
163
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12459
diff changeset
164 if (isempty (xi) && firstnumeric && ! ispp)
10820
c44c786f87ba interp1.m: When absent set X equal to the inices of Y.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
165 xi = y;
c44c786f87ba interp1.m: When absent set X equal to the inices of Y.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
166 y = x;
17088
c8586e6fc60d interp1.m: Fix interpolation on ND-arrays (bug #35860)
Mike Miller <mtmiller@ieee.org>
parents: 17087
diff changeset
167 if (isvector (y))
c8586e6fc60d interp1.m: Fix interpolation on ND-arrays (bug #35860)
Mike Miller <mtmiller@ieee.org>
parents: 17087
diff changeset
168 x = 1:numel (y);
c8586e6fc60d interp1.m: Fix interpolation on ND-arrays (bug #35860)
Mike Miller <mtmiller@ieee.org>
parents: 17087
diff changeset
169 else
c8586e6fc60d interp1.m: Fix interpolation on ND-arrays (bug #35860)
Mike Miller <mtmiller@ieee.org>
parents: 17087
diff changeset
170 x = 1:rows (y);
c8586e6fc60d interp1.m: Fix interpolation on ND-arrays (bug #35860)
Mike Miller <mtmiller@ieee.org>
parents: 17087
diff changeset
171 endif
10820
c44c786f87ba interp1.m: When absent set X equal to the inices of Y.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
172 endif
c44c786f87ba interp1.m: When absent set X equal to the inices of Y.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
173
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
174 ## reshape matrices for convenience
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
175 x = x(:);
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
176 nx = rows (x);
9769
9a1c4fe44af8 small interp1 simplification
Jaroslav Hajek <highegg@gmail.com>
parents: 9754
diff changeset
177 szx = size (xi);
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
178 if (isvector (y))
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
179 y = y(:);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
180 endif
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
181
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
182 szy = size (y);
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
183 y = y(:,:);
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
184 [ny, nc] = size (y);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
185 xi = xi(:);
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
186
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
187 ## determine sizes
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
188 if (nx < 2 || ny < 2)
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
189 error ("interp1: minimum of 2 points required in each dimension");
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
190 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
191
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
192 ## check whether x is sorted; sort if not.
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
193 if (! issorted (x, "either"))
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
194 [x, p] = sort (x);
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
195 y = y(p,:);
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
196 endif
5838
376e02b2ce70 [project @ 2006-06-01 20:23:53 by jwe]
jwe
parents: 5837
diff changeset
197
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
198 if (any (strcmp (method, {"previous", "*previous", "next", "*next"})))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
199 rightcontinuous = NaN; # needed for these methods to work
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
200 endif
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
201
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
202 if (isnan (rightcontinuous))
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
203 ## If not specified, set the continuity condition
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
204 if (x(end) < x(1))
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
205 rightcontinuous = false;
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
206 else
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
207 rightcontinuous = true;
17306
09543e9c8f40 Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents: 17281
diff changeset
208 endif
18676
a07814a8ffb0 interp1.m: Small formatting changes only.
Rik <rik@octave.org>
parents: 18669
diff changeset
209 elseif ((rightcontinuous && (x(end) < x(1)))
a07814a8ffb0 interp1.m: Small formatting changes only.
Rik <rik@octave.org>
parents: 18669
diff changeset
210 || (! rightcontinuous && (x(end) > x(1))))
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
211 ## Switch between left-continuous and right-continuous
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
212 x = flipud (x);
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
213 y = flipud (y);
17306
09543e9c8f40 Use explicit form of end (endif, endfor, etc.) in core m-files.
Rik <rik@octave.org>
parents: 17281
diff changeset
214 endif
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
215
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
216 ## Because of the way mkpp works, it's easiest to implement "next"
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
217 ## by running "previous" with vectors flipped.
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
218 if (strcmp (method, "next"))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
219 x = flipud (x);
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
220 y = flipud (y);
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
221 method = "previous";
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
222 elseif (strcmp (method, "*next"))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
223 x = flipud (x);
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
224 y = flipud (y);
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
225 method = "*previous";
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
226 endif
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
227
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
228 starmethod = method(1) == "*";
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
229
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
230 if (starmethod)
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
231 dx = x(2) - x(1);
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
232 else
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
233 jumps = x(1:end-1) == x(2:end);
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
234 have_jumps = any (jumps);
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
235 if (have_jumps)
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
236 if (strcmp (method, "linear") || strcmp (method, ("nearest")))
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
237 if (any (jumps(1:nx-2) & jumps(2:nx-1)))
18418
1ad77b3e6bef interp1.m: Demote error to warning about multiple discontinuties (bug #41386).
Rik <rik@octave.org>
parents: 18417
diff changeset
238 warning ("interp1: multiple discontinuities at the same X value");
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
239 endif
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
240 else
18676
a07814a8ffb0 interp1.m: Small formatting changes only.
Rik <rik@octave.org>
parents: 18669
diff changeset
241 error ("interp1: discontinuities not supported for method '%s'",
a07814a8ffb0 interp1.m: Small formatting changes only.
Rik <rik@octave.org>
parents: 18669
diff changeset
242 method);
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
243 endif
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
244 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
245 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
246
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
247 ## Proceed with interpolating by all methods.
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
248 switch (method)
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
249
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
250 case "nearest"
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
251 pp = mkpp ([x(1); (x(1:nx-1)+x(2:nx))/2; x(nx)],
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
252 shiftdim (y, 1), szy(2:end));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
253 pp.orient = "first";
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
254
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
255 if (ispp)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
256 yi = pp;
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
257 else
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
258 yi = ppval (pp, reshape (xi, szx));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
259 endif
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
260
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
261 case "*nearest"
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
262 pp = mkpp ([x(1), x(1)+[0.5:(nx-1)]*dx, x(nx)],
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
263 shiftdim (y, 1), szy(2:end));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
264 pp.orient = "first";
18676
a07814a8ffb0 interp1.m: Small formatting changes only.
Rik <rik@octave.org>
parents: 18669
diff changeset
265
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
266 if (ispp)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
267 yi = pp;
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
268 else
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
269 yi = ppval (pp, reshape (xi, szx));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
270 endif
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
271
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
272 case "previous"
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
273 pp = mkpp ([x(1:nx); 2*x(nx)-x(nx-1)],
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
274 shiftdim (y, 1), szy(2:end));
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
275 pp.orient = "first";
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
276
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
277 if (ispp)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
278 yi = pp;
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
279 else
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
280 yi = ppval (pp, reshape (xi, szx));
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
281 endif
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
282
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
283 case "*previous"
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
284 pp = mkpp (x(1)+[0:nx]*dx,
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
285 shiftdim (y, 1), szy(2:end));
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
286 pp.orient = "first";
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
287
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
288 if (ispp)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
289 yi = pp;
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
290 else
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
291 yi = ppval (pp, reshape (xi, szx));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
292 endif
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
293
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
294 case "linear"
18415
b06675ef40f2 interp1.m: Fix handling multi-column y-input with jumps (bug #40825).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 17744
diff changeset
295
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
296 xx = x;
18667
5fe907167520 interp1.m: fix function for inputs w/multiple discontinuities (bug #41980).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 18418
diff changeset
297 nxx = nx;
18415
b06675ef40f2 interp1.m: Fix handling multi-column y-input with jumps (bug #40825).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 17744
diff changeset
298 yy = y;
18667
5fe907167520 interp1.m: fix function for inputs w/multiple discontinuities (bug #41980).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 18418
diff changeset
299 dy = diff (yy);
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
300 if (have_jumps)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
301 ## Omit zero-size intervals.
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
302 xx(jumps) = [];
18415
b06675ef40f2 interp1.m: Fix handling multi-column y-input with jumps (bug #40825).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 17744
diff changeset
303 nxx = rows (xx);
18667
5fe907167520 interp1.m: fix function for inputs w/multiple discontinuities (bug #41980).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 18418
diff changeset
304 yy(jumps, :) = [];
5fe907167520 interp1.m: fix function for inputs w/multiple discontinuities (bug #41980).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 18418
diff changeset
305 dy(jumps, :) = [];
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
306 endif
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12459
diff changeset
307
18415
b06675ef40f2 interp1.m: Fix handling multi-column y-input with jumps (bug #40825).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 17744
diff changeset
308 dx = diff (xx);
b06675ef40f2 interp1.m: Fix handling multi-column y-input with jumps (bug #40825).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 17744
diff changeset
309 dx = repmat (dx, [1 size(dy)(2:end)]);
b06675ef40f2 interp1.m: Fix handling multi-column y-input with jumps (bug #40825).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 17744
diff changeset
310
18667
5fe907167520 interp1.m: fix function for inputs w/multiple discontinuities (bug #41980).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 18418
diff changeset
311 coefs = [(dy./dx).', yy(1:nxx-1, :).'];
18415
b06675ef40f2 interp1.m: Fix handling multi-column y-input with jumps (bug #40825).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 17744
diff changeset
312
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
313 pp = mkpp (xx, coefs, szy(2:end));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
314 pp.orient = "first";
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12459
diff changeset
315
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
316 if (ispp)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
317 yi = pp;
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
318 else
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
319 yi = ppval (pp, reshape (xi, szx));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
320 endif
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12459
diff changeset
321
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
322 case "*linear"
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
323 dy = diff (y);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
324 coefs = [(dy/dx).'(:), y(1:nx-1, :).'(:)];
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
325 pp = mkpp (x, coefs, szy(2:end));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
326 pp.orient = "first";
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12459
diff changeset
327
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
328 if (ispp)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
329 yi = pp;
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
330 else
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
331 yi = ppval (pp, reshape (xi, szx));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
332 endif
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
333
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
334 case {"pchip", "*pchip", "cubic", "*cubic"}
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
335 if (nx == 2 || starmethod)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
336 x = linspace (x(1), x(nx), ny);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
337 endif
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
338
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
339 if (ispp)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
340 y = shiftdim (reshape (y, szy), 1);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
341 yi = pchip (x, y);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
342 yi.orient = "first";
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
343 else
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
344 y = shiftdim (y, 1);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
345 yi = pchip (x, y, reshape (xi, szx));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
346 if (! isvector (y))
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
347 yi = shiftdim (yi, 1);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
348 endif
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
349 endif
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
350
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
351 case {"spline", "*spline"}
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
352 if (nx == 2 || starmethod)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
353 x = linspace (x(1), x(nx), ny);
14492
7ce925166af6 Fix inconsistent orientation of output matrix for interp1.
Olaf Till <i7tiol@t-online.de>
parents: 14363
diff changeset
354 endif
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
355
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
356 if (ispp)
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
357 y = shiftdim (reshape (y, szy), 1);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
358 yi = spline (x, y);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
359 yi.orient = "first";
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
360 else
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
361 y = shiftdim (y, 1);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
362 yi = spline (x, y, reshape (xi, szx));
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
363 if (! isvector (y))
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
364 yi = shiftdim (yi, 1);
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
365 endif
14492
7ce925166af6 Fix inconsistent orientation of output matrix for interp1.
Olaf Till <i7tiol@t-online.de>
parents: 14363
diff changeset
366 endif
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
367
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
368 otherwise
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17088
diff changeset
369 error ("interp1: invalid method '%s'", method);
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
370
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
371 endswitch
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
372
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
373 if (! ispp && isnumeric (extrap))
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
374 ## determine which values are out of range and set them to extrap,
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
375 ## unless extrap == "extrap".
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
376 minx = min (x(1), x(nx));
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
377 maxx = max (x(1), x(nx));
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
378
19417
ef649fe230f5 interp1.m: Fix shape of output matrix when there are extrapolated values (bug #43745).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18667
diff changeset
379 xi = reshape (xi, szx);
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
380 outliers = xi < minx | ! (xi <= maxx); # this even catches NaNs
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
381 if (size_equal (outliers, yi))
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
382 yi(outliers) = extrap;
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
383 yi = reshape (yi, szx);
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
384 elseif (! isvector (yi))
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
385 yi(outliers, :) = extrap;
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
386 else
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
387 yi(outliers.') = extrap;
9754
4219e5cf773d improve interp1 and pchip
Jaroslav Hajek <highegg@gmail.com>
parents: 9070
diff changeset
388 endif
19417
ef649fe230f5 interp1.m: Fix shape of output matrix when there are extrapolated values (bug #43745).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18667
diff changeset
389
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
390 endif
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
391
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
392 endfunction
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
393
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
394
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
395 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
396 %! clf;
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
397 %! xf = 0:0.05:10; yf = sin (2*pi*xf/5);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
398 %! xp = 0:10; yp = sin (2*pi*xp/5);
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
399 %! lin = interp1 (xp,yp,xf, 'linear');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
400 %! spl = interp1 (xp,yp,xf, 'spline');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
401 %! pch = interp1 (xp,yp,xf, 'pchip');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
402 %! near= interp1 (xp,yp,xf, 'nearest');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
403 %! plot (xf,yf,'r',xf,near,'g',xf,lin,'b',xf,pch,'c',xf,spl,'m',xp,yp,'r*');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
404 %! legend ('original', 'nearest', 'linear', 'pchip', 'spline');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
405 %! title ('Interpolation of continuous function sin (x) w/various methods');
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
406 %! %--------------------------------------------------------
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
407 %! % confirm that interpolated function matches the original
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
408
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
409 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
410 %! clf;
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
411 %! xf = 0:0.05:10; yf = sin (2*pi*xf/5);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
412 %! xp = 0:10; yp = sin (2*pi*xp/5);
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
413 %! lin = interp1 (xp,yp,xf, '*linear');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
414 %! spl = interp1 (xp,yp,xf, '*spline');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
415 %! pch = interp1 (xp,yp,xf, '*pchip');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
416 %! near= interp1 (xp,yp,xf, '*nearest');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
417 %! plot (xf,yf,'r',xf,near,'g',xf,lin,'b',xf,pch,'c',xf,spl,'m',xp,yp,'r*');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
418 %! legend ('*original', '*nearest', '*linear', '*pchip', '*spline');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
419 %! title ('Interpolation of continuous function sin (x) w/various *methods');
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
420 %! %--------------------------------------------------------
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
421 %! % confirm that interpolated function matches the original
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
422
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
423 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
424 %! clf;
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
425 %! fstep = @(x) x > 1;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
426 %! xf = 0:0.05:2; yf = fstep (xf);
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
427 %! xp = linspace (0,2,10); yp = fstep (xp);
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
428 %! pch = interp1 (xp,yp,xf, 'pchip');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
429 %! spl = interp1 (xp,yp,xf, 'spline');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
430 %! plot (xf,yf,'r',xf,pch,'b',xf,spl,'m',xp,yp,'r*');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
431 %! title ({'Interpolation of step function with discontinuity at x==1', ...
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
432 %! 'Note: "pchip" is shape-preserving, "spline" (continuous 1st, 2nd derivatives) is not'});
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
433 %! legend ('original', 'pchip', 'spline');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
434
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
435 %!demo
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
436 %! clf;
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
437 %! t = 0 : 0.3 : pi; dt = t(2)-t(1);
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
438 %! n = length (t); k = 100; dti = dt*n/k;
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
439 %! ti = t(1) + [0 : k-1]*dti;
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
440 %! y = sin (4*t + 0.3) .* cos (3*t - 0.1);
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
441 %! ddys = diff (diff (interp1 (t,y,ti, 'spline'))./dti)./dti;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
442 %! ddyp = diff (diff (interp1 (t,y,ti, 'pchip')) ./dti)./dti;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
443 %! ddyc = diff (diff (interp1 (t,y,ti, 'cubic')) ./dti)./dti;
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
444 %! plot (ti(2:end-1),ddys,'b*', ti(2:end-1),ddyp,'c^', ti(2:end-1),ddyc,'g+');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
445 %! title ({'Second derivative of interpolated "sin (4*t + 0.3) .* cos (3*t - 0.1)"', ...
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
446 %! 'Note: "spline" has continous 2nd derivative, others do not'});
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
447 %! legend ('spline', 'pchip', 'cubic');
6721
01036667884a [project @ 2007-06-14 06:56:41 by dbateman]
dbateman
parents: 6702
diff changeset
448
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
449 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
450 %! clf;
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
451 %! xf = 0:0.05:10; yf = sin (2*pi*xf/5) - (xf >= 5);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
452 %! xp = [0:.5:4.5,4.99,5:.5:10]; yp = sin (2*pi*xp/5) - (xp >= 5);
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
453 %! lin = interp1 (xp,yp,xf, 'linear');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
454 %! near= interp1 (xp,yp,xf, 'nearest');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
455 %! plot (xf,yf,'r', xf,near,'g', xf,lin,'b', xp,yp,'r*');
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
456 %! legend ('original', 'nearest', 'linear');
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
457 %! %--------------------------------------------------------
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
458 %! % confirm that interpolated function matches the original
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
459
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
460 %!demo
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
461 %! clf;
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
462 %! x = 0:0.5:3;
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
463 %! x1 = [3 2 2 1];
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
464 %! x2 = [1 2 2 3];
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
465 %! y1 = [1 1 0 0];
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
466 %! y2 = [0 0 1 1];
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
467 %! h = plot (x, interp1 (x1, y1, x), 'b', x1, y1, 'sb');
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
468 %! hold on
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
469 %! g = plot (x, interp1 (x2, y2, x), 'r', x2, y2, '*r');
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
470 %! axis ([0.5 3.5 -0.5 1.5])
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
471 %! legend ([h(1), g(1)], {'left-continuous', 'right-continuous'}, ...
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
472 %! 'location', 'northwest')
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
473 %! legend boxoff
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
474 %! %--------------------------------------------------------
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
475 %! % red curve is left-continuous and blue is right-continuous at x = 2
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
476
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
477 ##FIXME: add test for N-d arguments here
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
478
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
479 ## For each type of interpolated test, confirm that the interpolated
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
480 ## value at the knots match the values at the knots. Points away
14359
7277fe922e99 doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents: 14335
diff changeset
481 ## from the knots are requested, but only "nearest" and "linear"
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
482 ## confirm they are the correct values.
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
483
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
484 %!shared xp, yp, xi, style
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
485 %! xp = 0:2:10;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
486 %! yp = sin (2*pi*xp/5);
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
487 %! xi = [-1, 0, 2.2, 4, 6.6, 10, 11];
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
488
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
489 ## The following BLOCK/ENDBLOCK section is repeated for each style
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
490 ## nearest, previous, next, linear, cubic, spline, pchip
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
491 ## The test for ppval of cubic has looser tolerance, but otherwise
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
492 ## the tests are identical.
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
493 ## Note that the block checks style and *style; if you add more tests
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
494 ## be sure to add them to both sections of each block. One test,
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
495 ## style vs. *style, occurs only in the first section.
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
496 ## There is an ENDBLOCKTEST after the final block
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
497
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
498 %!test style = "nearest";
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
499 ## BLOCK
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
500 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
501 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
502 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
503 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
504 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
505 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
506 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
507 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
508 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
509 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
510 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
511 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
512 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
513 %!error interp1 (1,1,1, style)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
514 %!assert (interp1 (xp,[yp',yp'],xi,style),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
515 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
516 %!test style = ["*",style];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
517 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
518 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
519 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
520 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
521 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
522 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
523 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
524 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
525 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
526 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
527 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
528 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
529 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
530 %!error interp1 (1,1,1, style)
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
531 ## ENDBLOCK
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
532
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
533 %!test style = "previous";
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
534 ## BLOCK
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
535 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
536 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
537 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
538 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
539 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
540 %!assert (isempty (interp1 (xp',yp',[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
541 %!assert (isempty (interp1 (xp,yp,[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
542 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
543 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
544 ## This test is expected to fail, so commented out.
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
545 ## "previous" and "next" options are not symmetric w.r.t to flipping xp,yp
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
546 #%!assert (interp1 (xp,yp,xi,style),...
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
547 #%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
548 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
549 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
550 %!error interp1 (1,1,1, style)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
551 %!assert (interp1 (xp,[yp',yp'],xi,style),
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
552 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
553 %!test style = ["*",style];
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
554 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
555 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
556 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
557 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
558 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
559 %!assert (isempty (interp1 (xp',yp',[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
560 %!assert (isempty (interp1 (xp,yp,[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
561 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
562 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
563 # %!assert (interp1 (xp,yp,xi,style),...
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
564 # %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
565 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
566 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
567 %!error interp1 (1,1,1, style)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
568 ## ENDBLOCK
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
569
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
570 %!test style = "next";
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
571 ## BLOCK
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
572 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
573 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
574 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
575 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
576 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
577 %!assert (isempty (interp1 (xp',yp',[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
578 %!assert (isempty (interp1 (xp,yp,[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
579 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
580 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
581 # %!assert (interp1 (xp,yp,xi,style),...
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
582 # %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
583 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
584 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
585 %!error interp1 (1,1,1, style)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
586 %!assert (interp1 (xp,[yp',yp'],xi,style),
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
587 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
588 %!test style = ["*",style];
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
589 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
590 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
591 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
592 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
593 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
594 %!assert (isempty (interp1 (xp',yp',[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
595 %!assert (isempty (interp1 (xp,yp,[],style)))
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
596 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
597 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
598 # %!assert (interp1 (xp,yp,xi,style),...
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
599 # %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
600 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
601 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
602 %!error interp1 (1,1,1, style)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
603 ## ENDBLOCK
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
604
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
605 %!test style = "linear";
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
606 ## BLOCK
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
607 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
608 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
609 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
610 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
611 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
612 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
613 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
614 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
615 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
616 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
617 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
618 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
619 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
620 %!error interp1 (1,1,1, style)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
621 %!assert (interp1 (xp,[yp',yp'],xi,style),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
622 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
623 %!test style = ['*',style];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
624 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
625 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
626 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
627 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
628 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
629 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
630 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
631 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
632 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
633 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
634 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
635 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
636 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
15218
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
637 %!assert (interp1 ([1 2 2 3], [1 2 3 4], 2), 3);
94d512d712e3 Modified interp1.m file to check whether X has distinct values or not.
Ben Abbott <bpabbott@mac.com>
parents: 15193
diff changeset
638 %!assert (interp1 ([3 2 2 1], [4 3 2 1], 2), 2);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
639 %!error interp1 (1,1,1, style)
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
640 ## ENDBLOCK
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
641
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
642 %!test style = "cubic";
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
643 ## BLOCK
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
644 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
645 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
646 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
647 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
648 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
649 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
650 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
651 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
652 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
653 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
654 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
655 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
656 %! interp1 (xp,yp,xi,style,"extrap"),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
657 %!error interp1 (1,1,1, style)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
658 %!assert (interp1 (xp,[yp',yp'],xi,style),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
659 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
660 %!test style = ["*",style];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
661 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
662 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
663 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
664 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
665 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
666 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
667 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
668 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
669 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
670 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
671 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
672 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
673 %! interp1 (xp,yp,xi,style,"extrap"),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
674 %!error interp1 (1,1,1, style)
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
675 ## ENDBLOCK
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
676
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
677 %!test style = "pchip";
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
678 ## BLOCK
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
679 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
680 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
681 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
682 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
683 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
684 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
685 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
686 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
687 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
688 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
689 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
690 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
691 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
692 %!error interp1 (1,1,1, style)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
693 %!assert (interp1 (xp,[yp',yp'],xi,style),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
694 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
695 %!test style = ["*",style];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
696 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
697 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
698 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
699 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
700 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
701 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
702 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
703 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
704 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
705 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
706 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
707 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
708 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
709 %!error interp1 (1,1,1, style)
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
710 ## ENDBLOCK
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
711
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
712 %!test style = "spline";
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
713 ## BLOCK
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
714 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
715 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
716 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
717 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
718 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
719 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
720 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
721 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
722 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
723 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
724 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
725 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
726 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
727 %!error interp1 (1,1,1, style)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
728 %!assert (interp1 (xp,[yp',yp'],xi,style),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
729 %! interp1 (xp,[yp',yp'],xi,["*",style]),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
730 %!test style = ["*",style];
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
731 %!assert (interp1 (xp, yp, [min(xp)-1, max(xp)+1],style), [NA, NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
732 %!assert (interp1 (xp,yp,xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
733 %!assert (interp1 (xp,yp,xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
734 %!assert (interp1 (xp',yp',xp',style), yp', 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
735 %!assert (interp1 (xp',yp',xp,style), yp, 100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
736 %!assert (isempty (interp1 (xp',yp',[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
737 %!assert (isempty (interp1 (xp,yp,[],style)))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
738 %!assert (interp1 (xp,[yp',yp'],xi(:),style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
739 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
740 %!assert (interp1 (xp,yp,xi,style),...
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
741 %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
742 %!assert (ppval (interp1 (xp,yp,style,"pp"),xi),
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
743 %! interp1 (xp,yp,xi,style,"extrap"),10*eps)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
744 %!error interp1 (1,1,1, style)
6374
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
745 ## ENDBLOCK
419017274c1e [project @ 2007-03-01 15:57:50 by jwe]
jwe
parents: 6366
diff changeset
746 ## ENDBLOCKTEST
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
747
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
748 ## test extrapolation
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
749 %!assert (interp1 ([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps)
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
750 %!assert (interp1 ([1:5],[3:2:11],[0,6],"nearest","extrap"), [3, 11], eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
751 %!assert (interp1 ([1:5],[3:2:11],[0,6],"previous","extrap"), [3, 11], eps)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
752 %!assert (interp1 ([1:5],[3:2:11],[0,6],"next","extrap"), [3, 11], eps)
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
753 %!assert (interp1 (xp, yp, [-1, max(xp)+1],"linear",5), [5, 5])
19417
ef649fe230f5 interp1.m: Fix shape of output matrix when there are extrapolated values (bug #43745).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18667
diff changeset
754 %!assert (interp1 ([0,1],[1,0],[0.1,0.9;0.2,1.1]), [0.9 0.1; 0.8 NA], eps)
ef649fe230f5 interp1.m: Fix shape of output matrix when there are extrapolated values (bug #43745).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18667
diff changeset
755 %!assert (interp1 ([0,1],[1,0],[0.1,0.9;0.2,1]), [0.9 0.1; 0.8 0], eps)
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
756
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
757 ## Basic sanity checks
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
758 %!assert (interp1 (1:2,1:2,1.4,"nearest"), 1)
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
759 %!assert (interp1 (1:2,1:2,1.6,"previous"), 1)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
760 %!assert (interp1 (1:2,1:2,1.4,"next"), 2)
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
761 %!assert (interp1 (1:2,1:2,1.4,"linear"), 1.4)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
762 %!assert (interp1 (1:4,1:4,1.4,"cubic"), 1.4)
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
763 %!assert (interp1 (1:2,1:2,1.1,"spline"), 1.1)
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
764 %!assert (interp1 (1:3,1:3,1.4,"spline"), 1.4)
5837
55404f3b0da1 [project @ 2006-06-01 19:05:31 by jwe]
jwe
parents:
diff changeset
765
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
766 %!assert (interp1 (1:2:4,1:2:4,1.4,"*nearest"), 1)
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
767 %!assert (interp1 (1:2:4,1:2:4,2.2,"*previous"), 1)
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
768 %!assert (interp1 (1:2:4,1:2:4,1.4,"*next"), 3)
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
769 %!assert (interp1 (1:2:4,1:2:4,[0,1,1.4,3,4],"*linear"), [NA,1,1.4,3,NA])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
770 %!assert (interp1 (1:2:8,1:2:8,1.4,"*cubic"), 1.4)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
771 %!assert (interp1 (1:2,1:2,1.3, "*spline"), 1.3)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
772 %!assert (interp1 (1:2:6,1:2:6,1.4,"*spline"), 1.4)
7671
4fbaba9abec1 implement compiled binary lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
773
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
774 %!assert (interp1 ([3,2,1],[3,2,2],2.5), 2.5)
9929
45c08d7c2c79 allow discontinuous interpolant in interp1
Jaroslav Hajek <highegg@gmail.com>
parents: 9769
diff changeset
775
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 12459
diff changeset
776 %!assert (interp1 ([4,4,3,2,0],[0,1,4,2,1],[1.5,4,4.5], "linear"), [1.75,1,NA])
10820
c44c786f87ba interp1.m: When absent set X equal to the inices of Y.
Ben Abbott <bpabbott@mac.com>
parents: 10793
diff changeset
777 %!assert (interp1 (0:4, 2.5), 1.5)
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
778
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
779 ## Left and Right discontinuities
18667
5fe907167520 interp1.m: fix function for inputs w/multiple discontinuities (bug #41980).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 18418
diff changeset
780 %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "right"), [-2,0.5,4,3,1.5])
5fe907167520 interp1.m: fix function for inputs w/multiple discontinuities (bug #41980).
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents: 18418
diff changeset
781 %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "left"), [-2,0.5,1,3,1.5])
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
782
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
783 %% Test input validation
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
784 %!error interp1 ()
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
785 %!error interp1 (1,2,3,4,5,6,7)
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
786 %!error <minimum of 2 points required> interp1 (1,1,1, "linear")
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
787 %!error <minimum of 2 points required> interp1 (1,1,1, "*nearest")
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
788 %!error <minimum of 2 points required> interp1 (1,1,1, "*linear")
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
789 %!error <minimum of 2 points required> interp1 (1,1,1, "previous")
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
790 %!error <minimum of 2 points required> interp1 (1,1,1, "*previous")
18418
1ad77b3e6bef interp1.m: Demote error to warning about multiple discontinuties (bug #41386).
Rik <rik@octave.org>
parents: 18417
diff changeset
791 %!warning <multiple discontinuities> interp1 ([1 1 1 2], [1 2 3 4], 1);
19328
b80b396e7d54 interp1.m: Add new methods "previous" and "next" (bug #43377).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 18676
diff changeset
792 %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "next")
18417
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
793 %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "pchip")
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
794 %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "cubic")
71d1a1450365 interp1.m: Clean up function
Rik <rik@octave.org>
parents: 18415
diff changeset
795 %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "spline")
18640
0ede4dbb37f1 Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents: 18418
diff changeset
796 %!error <invalid method 'bogus'> interp1 (1:2,1:2,1, "bogus")
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
797