Mercurial > octave-nkf
annotate scripts/geometry/griddata.m @ 20193:7503499a252b stable
doc: Update docstrings to have one sentence summary as first line.
Update scripts in audio, elfun, general, geometry, and image directories.
* scripts/audio/@audioplayer/__get_properties__.m,
scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m,
scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m,
scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m,
scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m,
scripts/audio/@audiorecorder/audiorecorder.m,
scripts/audio/@audiorecorder/get.m,
scripts/audio/@audiorecorder/getaudiodata.m,
scripts/audio/@audiorecorder/getplayer.m,
scripts/audio/@audiorecorder/isrecording.m,
scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m,
scripts/audio/@audiorecorder/recordblocking.m,
scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m,
scripts/audio/@audiorecorder/subsasgn.m,
scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m,
scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m,
scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m,
scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m,
scripts/general/accumarray.m, scripts/general/accumdim.m,
scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m,
scripts/general/blkdiag.m, scripts/general/cart2pol.m,
scripts/general/cart2sph.m, scripts/general/cell2mat.m,
scripts/general/celldisp.m, scripts/general/chop.m,
scripts/general/circshift.m, scripts/general/common_size.m,
scripts/general/cplxpair.m, scripts/general/cumtrapz.m,
scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m,
scripts/general/display.m, scripts/general/divergence.m,
scripts/general/fieldnames.m, scripts/general/flip.m,
scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m,
scripts/general/gradient.m, scripts/general/interp3.m,
scripts/general/interpft.m, scripts/general/interpn.m,
scripts/general/loadobj.m, scripts/general/logspace.m,
scripts/general/methods.m, scripts/general/nargchk.m,
scripts/general/narginchk.m, scripts/general/nargoutchk.m,
scripts/general/nextpow2.m, scripts/general/nthargout.m,
scripts/general/num2str.m, scripts/general/pol2cart.m,
scripts/general/polyarea.m, scripts/general/postpad.m,
scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m,
scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m,
scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m,
scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m,
scripts/general/shiftdim.m, scripts/general/sortrows.m,
scripts/general/sph2cart.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/trapz.m,
scripts/general/triplequad.m, scripts/geometry/delaunayn.m,
scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m,
scripts/geometry/griddata.m, scripts/geometry/griddata3.m,
scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m,
scripts/geometry/rectint.m, scripts/geometry/tsearchn.m,
scripts/geometry/voronoi.m, scripts/geometry/voronoin.m,
scripts/help/__unimplemented__.m, scripts/help/doc.m,
scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m,
scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m,
scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m,
scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m,
scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m,
scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m,
scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m,
scripts/image/hot.m, scripts/image/hsv.m, scripts/image/image.m,
scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m,
scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m,
scripts/image/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m,
scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m,
scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m,
scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m,
scripts/image/white.m, scripts/image/winter.m:
Update docstrings to have one sentence summary as first line.
Re-structure to have line lengths <= 80 chars.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 03 May 2015 09:36:20 -0700 |
parents | 9fc020886ae9 |
children | 561af1ab6099 |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19627
diff
changeset
|
1 ## Copyright (C) 1999-2015 Kai Habel |
6823 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6823 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6823 | 18 |
19 ## -*- texinfo -*- | |
14372
3f6489feca1e
griddata.m: Update docstring.
Rik <octave@nomad.inbox5.com>
parents:
14368
diff
changeset
|
20 ## @deftypefn {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}) |
3f6489feca1e
griddata.m: Update docstring.
Rik <octave@nomad.inbox5.com>
parents:
14368
diff
changeset
|
21 ## @deftypefnx {Function File} {@var{zi} =} griddata (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{method}) |
3f6489feca1e
griddata.m: Update docstring.
Rik <octave@nomad.inbox5.com>
parents:
14368
diff
changeset
|
22 ## @deftypefnx {Function File} {[@var{xi}, @var{yi}, @var{zi}] =} griddata (@dots{}) |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
23 ## |
6823 | 24 ## Generate a regular mesh from irregular data using interpolation. |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
25 ## |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
26 ## The function is defined by @code{@var{z} = f (@var{x}, @var{y})}. Inputs |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
27 ## @code{@var{x}, @var{y}, @var{z}} are vectors of the same length or |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
28 ## @code{@var{x}, @var{y}} are vectors and @code{@var{z}} is matrix. |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
29 ## |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
30 ## The interpolation points are all @code{(@var{xi}, @var{yi})}. If @var{xi}, |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
31 ## @var{yi} are vectors then they are made into a 2-D mesh. |
6823 | 32 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
33 ## The interpolation method can be @qcode{"nearest"}, @qcode{"cubic"} or |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
34 ## @qcode{"linear"}. If method is omitted it defaults to @qcode{"linear"}. |
14372
3f6489feca1e
griddata.m: Update docstring.
Rik <octave@nomad.inbox5.com>
parents:
14368
diff
changeset
|
35 ## @seealso{griddata3, griddatan, delaunay} |
6823 | 36 ## @end deftypefn |
37 | |
10549 | 38 ## Author: Kai Habel <kai.habel@gmx.de> |
6823 | 39 ## Adapted-by: Alexander Barth <barth.alexander@gmail.com> |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
40 ## xi and yi are not "meshgridded" if both are vectors |
6823 | 41 ## of the same size (for compatibility) |
42 | |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
43 function [rx, ry, rz] = griddata (x, y, z, xi, yi, method = "linear") |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
44 |
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
45 if (nargin < 5 || nargin > 7) |
6826 | 46 print_usage (); |
6823 | 47 endif |
48 | |
6826 | 49 if (ischar (method)) |
50 method = tolower (method); | |
6823 | 51 endif |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
52 |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
53 ## Meshgrid if x and y are vectors but z is matrix |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
54 if (isvector (x) && isvector (y) && all ([numel(y), numel(x)] == size (z))) |
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
55 [x, y] = meshgrid (x, y); |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
56 endif |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
57 |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
58 if (isvector (x) && isvector (y) && isvector (z)) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
59 if (! isequal (length (x), length (y), length (z))) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
60 error ("griddata: X, Y, and Z must be vectors of the same length"); |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
61 endif |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
62 elseif (! size_equal (x, y, z)) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
63 error ("griddata: lengths of X, Y must match the columns and rows of Z"); |
6823 | 64 endif |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
65 |
9677
8cf522ce9c4d
fix griddata with vectors
Jaroslav Hajek <highegg@gmail.com>
parents:
9501
diff
changeset
|
66 ## Meshgrid xi and yi if they are a row and column vector. |
8cf522ce9c4d
fix griddata with vectors
Jaroslav Hajek <highegg@gmail.com>
parents:
9501
diff
changeset
|
67 if (rows (xi) == 1 && columns (yi) == 1) |
6826 | 68 [xi, yi] = meshgrid (xi, yi); |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
69 elseif (isvector (xi) && isvector (yi)) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
70 ## Otherwise, convert to column vectors |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
71 xi = xi(:); |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
72 yi = yi(:); |
6823 | 73 endif |
74 | |
9677
8cf522ce9c4d
fix griddata with vectors
Jaroslav Hajek <highegg@gmail.com>
parents:
9501
diff
changeset
|
75 if (! size_equal (xi, yi)) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10945
diff
changeset
|
76 error ("griddata: XI and YI must be vectors or matrices of same size"); |
6823 | 77 endif |
78 | |
9501 | 79 x = x(:); |
80 y = y(:); | |
81 z = z(:); | |
9495 | 82 |
8507 | 83 ## Triangulate data. |
6826 | 84 tri = delaunay (x, y); |
10548
479536c5bb10
Replace lowercase nan with NaN for visual cue in scripts
Rik <code@nomad.inbox5.com>
parents:
9677
diff
changeset
|
85 zi = NaN (size (xi)); |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
86 |
6826 | 87 if (strcmp (method, "cubic")) |
8664 | 88 error ("griddata: cubic interpolation not yet implemented"); |
6823 | 89 |
6826 | 90 elseif (strcmp (method, "nearest")) |
8507 | 91 ## Search index of nearest point. |
6826 | 92 idx = dsearch (x, y, tri, xi, yi); |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
93 valid = ! isnan (idx); |
6823 | 94 zi(valid) = z(idx(valid)); |
95 | |
6826 | 96 elseif (strcmp (method, "linear")) |
8507 | 97 ## Search for every point the enclosing triangle. |
98 tri_list = tsearch (x, y, tri, xi(:), yi(:)); | |
6823 | 99 |
8507 | 100 ## Only keep the points within triangles. |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
101 valid = ! isnan (tri_list); |
9496 | 102 tri_list = tri_list(valid); |
6826 | 103 nr_t = rows (tri_list); |
6823 | 104 |
9496 | 105 tri = tri(tri_list,:); |
106 | |
8507 | 107 ## Assign x,y,z for each point of triangle. |
9496 | 108 x1 = x(tri(:,1)); |
109 x2 = x(tri(:,2)); | |
110 x3 = x(tri(:,3)); | |
6826 | 111 |
9496 | 112 y1 = y(tri(:,1)); |
113 y2 = y(tri(:,2)); | |
114 y3 = y(tri(:,3)); | |
6826 | 115 |
9496 | 116 z1 = z(tri(:,1)); |
117 z2 = z(tri(:,2)); | |
118 z3 = z(tri(:,3)); | |
6823 | 119 |
8507 | 120 ## Calculate norm vector. |
6826 | 121 N = cross ([x2-x1, y2-y1, z2-z1], [x3-x1, y3-y1, z3-z1]); |
9496 | 122 ## Normalize. |
123 N = diag (norm (N, "rows")) \ N; | |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
124 |
8507 | 125 ## Calculate D of plane equation |
126 ## Ax+By+Cz+D = 0; | |
6823 | 127 D = -(N(:,1) .* x1 + N(:,2) .* y1 + N(:,3) .* z1); |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
128 |
8507 | 129 ## Calculate zi by solving plane equation for xi, yi. |
9677
8cf522ce9c4d
fix griddata with vectors
Jaroslav Hajek <highegg@gmail.com>
parents:
9501
diff
changeset
|
130 zi(valid) = -(N(:,1).*xi(:)(valid) + N(:,2).*yi(:)(valid) + D) ./ N(:,3); |
10945
aa40bdbfa478
griddata.m: Allow x, y inputs to be vectors, and z a matrix.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
131 |
6823 | 132 else |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10945
diff
changeset
|
133 error ("griddata: unknown interpolation METHOD"); |
6823 | 134 endif |
135 | |
6826 | 136 if (nargout == 3) |
6823 | 137 rx = xi; |
138 ry = yi; | |
139 rz = zi; | |
6826 | 140 elseif (nargout == 1) |
6823 | 141 rx = zi; |
6826 | 142 elseif (nargout == 0) |
143 mesh (xi, yi, zi); | |
6823 | 144 endif |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
145 |
6823 | 146 endfunction |
147 | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
148 |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
149 %!demo |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
150 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
151 %! colormap ("default"); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
152 %! x = 2*rand (100,1) - 1; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
153 %! y = 2*rand (size (x)) - 1; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
154 %! z = sin (2*(x.^2 + y.^2)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
155 %! [xx,yy] = meshgrid (linspace (-1,1,32)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
156 %! griddata (x,y,z,xx,yy); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
157 %! title ("nonuniform grid sampled at 100 points"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
158 |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
159 %!demo |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
160 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
161 %! colormap ("default"); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
162 %! x = 2*rand (1000,1) - 1; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
163 %! y = 2*rand (size (x)) - 1; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
164 %! z = sin (2*(x.^2 + y.^2)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
165 %! [xx,yy] = meshgrid (linspace (-1,1,32)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
166 %! griddata (x,y,z,xx,yy); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
167 %! title ("nonuniform grid sampled at 1000 points"); |
6823 | 168 |
169 %!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
|
170 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
171 %! colormap ("default"); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
172 %! x = 2*rand (1000,1) - 1; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
173 %! y = 2*rand (size (x)) - 1; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
174 %! z = sin (2*(x.^2 + y.^2)); |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
175 %! [xx,yy] = meshgrid (linspace (-1,1,32)); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
176 %! griddata (x,y,z,xx,yy,"nearest"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
177 %! title ("nonuniform grid sampled at 1000 points with nearest neighbor"); |
6823 | 178 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
179 %!testif HAVE_QHULL |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
180 %! [xx,yy] = meshgrid (linspace (-1,1,32)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
181 %! x = xx(:); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14372
diff
changeset
|
182 %! x = x + 10*(2*round (rand (size (x))) - 1) * eps; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
183 %! y = yy(:); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14372
diff
changeset
|
184 %! y = y + 10*(2*round (rand (size (y))) - 1) * eps; |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
185 %! z = sin (2*(x.^2 + y.^2)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
186 %! zz = griddata (x,y,z,xx,yy,"linear"); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
187 %! zz2 = sin (2*(xx.^2 + yy.^2)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
188 %! zz2(isnan (zz)) = NaN; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
189 %! assert (zz, zz2, 100*eps); |
6823 | 190 |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
191 ## Test input validation |
14368
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
192 %!error griddata () |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
193 %!error griddata (1) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
194 %!error griddata (1,2) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
195 %!error griddata (1,2,3) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
196 %!error griddata (1,2,3,4) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
197 %!error griddata (1,2,3,4,5,6,7) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
198 %!error <vectors of the same length> griddata (1:3, 1:3, 1:4, 1:3, 1:3) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
199 %!error <vectors of the same length> griddata (1:3, 1:4, 1:3, 1:3, 1:3) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
200 %!error <vectors of the same length> griddata (1:4, 1:3, 1:3, 1:3, 1:3) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
201 %!error <the columns and rows of Z> griddata (1:4, 1:3, ones (4,4), 1:3, 1:3) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
202 %!error <the columns and rows of Z> griddata (1:4, 1:3, ones (3,5), 1:3, 1:3) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
203 %!error <matrices of same size> griddata (1:3, 1:3, 1:3, 1:4, 1:3) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
204 %!error <matrices of same size> griddata (1:3, 1:3, 1:3, 1:3, 1:4) |
5736d93b22d0
griddata.m: Accept vectors in any orientation (Bug #33539)
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
205 |