Mercurial > octave-nkf
comparison scripts/general/interpn.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | 62bb59f927b1 |
children | d1978e7364ad |
comparison
equal
deleted
inserted
replaced
10548:479536c5bb10 | 10549:95c3e38098bf |
---|---|
87 v = varargin{1}; | 87 v = varargin{1}; |
88 m = 1; | 88 m = 1; |
89 if (nargs == 2) | 89 if (nargs == 2) |
90 m = varargin{2}; | 90 m = varargin{2}; |
91 if (! isnumeric (m) || ! isscalar (m) || floor (m) != m) | 91 if (! isnumeric (m) || ! isscalar (m) || floor (m) != m) |
92 error ("m is expected to be a integer scalar"); | 92 error ("m is expected to be a integer scalar"); |
93 endif | 93 endif |
94 endif | 94 endif |
95 sz = size (v); | 95 sz = size (v); |
96 nd = ndims (v); | 96 nd = ndims (v); |
97 x = cell (1, nd); | 97 x = cell (1, nd); |
108 y = varargin (2 : nargs); | 108 y = varargin (2 : nargs); |
109 for i = 1 : nd; | 109 for i = 1 : nd; |
110 x{i} = 1 : sz(i); | 110 x{i} = 1 : sz(i); |
111 endfor | 111 endfor |
112 elseif (rem (nargs, 2) == 1 && nargs == | 112 elseif (rem (nargs, 2) == 1 && nargs == |
113 (2 * ndims (varargin{ceil (nargs / 2)})) + 1) | 113 (2 * ndims (varargin{ceil (nargs / 2)})) + 1) |
114 nv = ceil (nargs / 2); | 114 nv = ceil (nargs / 2); |
115 v = varargin{nv}; | 115 v = varargin{nv}; |
116 sz = size (v); | 116 sz = size (v); |
117 nd = ndims (v); | 117 nd = ndims (v); |
118 x = varargin (1 : (nv - 1)); | 118 x = varargin (1 : (nv - 1)); |
122 endif | 122 endif |
123 | 123 |
124 if (any (! cellfun (@isvector, x))) | 124 if (any (! cellfun (@isvector, x))) |
125 for i = 2 : nd | 125 for i = 2 : nd |
126 if (! size_equal (x{1}, x{i}) || ! size_equal (x{i}, v)) | 126 if (! size_equal (x{1}, x{i}) || ! size_equal (x{i}, v)) |
127 error ("dimensional mismatch"); | 127 error ("dimensional mismatch"); |
128 endif | 128 endif |
129 idx (1 : nd) = {1}; | 129 idx (1 : nd) = {1}; |
130 idx (i) = ":"; | 130 idx (i) = ":"; |
131 x{i} = x{i}(idx{:})(:); | 131 x{i} = x{i}(idx{:})(:); |
132 endfor | 132 endfor |
159 vi(idx) = extrapval; | 159 vi(idx) = extrapval; |
160 vi = reshape (vi, yshape); | 160 vi = reshape (vi, yshape); |
161 elseif (strcmp (method, "spline")) | 161 elseif (strcmp (method, "spline")) |
162 if (any (! cellfun (@isvector, y))) | 162 if (any (! cellfun (@isvector, y))) |
163 for i = 2 : nd | 163 for i = 2 : nd |
164 if (! size_equal (y{1}, y{i})) | 164 if (! size_equal (y{1}, y{i})) |
165 error ("dimensional mismatch"); | 165 error ("dimensional mismatch"); |
166 endif | 166 endif |
167 idx (1 : nd) = {1}; | 167 idx (1 : nd) = {1}; |
168 idx (i) = ":"; | 168 idx (i) = ":"; |
169 y{i} = y{i}(idx{:}); | 169 y{i} = y{i}(idx{:}); |
170 endfor | 170 endfor |
171 idx (1 : nd) = {1}; | 171 idx (1 : nd) = {1}; |
172 idx (1) = ":"; | 172 idx (1) = ":"; |
173 y{1} = y{1}(idx{:}); | 173 y{1} = y{1}(idx{:}); |
174 endif | 174 endif |
178 if (size_equal (y{:})) | 178 if (size_equal (y{:})) |
179 ly = length (y{1}); | 179 ly = length (y{1}); |
180 idx = cell (1, ly); | 180 idx = cell (1, ly); |
181 q = cell (1, nd); | 181 q = cell (1, nd); |
182 for i = 1 : ly | 182 for i = 1 : ly |
183 q(:) = i; | 183 q(:) = i; |
184 idx {i} = q; | 184 idx {i} = q; |
185 endfor | 185 endfor |
186 vi = vi (cellfun (@(x) sub2ind (size(vi), x{:}), idx)); | 186 vi = vi (cellfun (@(x) sub2ind (size(vi), x{:}), idx)); |
187 vi = reshape (vi, size(y{1})); | 187 vi = reshape (vi, size(y{1})); |
188 endif | 188 endif |
189 elseif (strcmp (method, "cubic")) | 189 elseif (strcmp (method, "cubic")) |