comparison scripts/general/interp3.m @ 19833:9fc020886ae9

maint: Clean up m-files to follow Octave coding conventions. Try to trim long lines to < 80 chars. Use '##' for single line comments. Use '(...)' around tests for if/elseif/switch/while. Abut cell indexing operator '{' next to variable. Abut array indexing operator '(' next to variable. Use space between negation operator '!' and following expression. Use two newlines between endfunction and start of %!test or %!demo code. Remove unnecessary parens grouping between short-circuit operators. Remove stray extra spaces (typos) between variables and assignment operators. Remove stray extra spaces from ends of lines.
author Rik <rik@octave.org>
date Mon, 23 Feb 2015 14:54:39 -0800
parents ca7599ae464d
children 7503499a252b
comparison
equal deleted inserted replaced
19832:a1acca0c2216 19833:9fc020886ae9
190 endif 190 endif
191 191
192 endfunction 192 endfunction
193 193
194 194
195 %% FIXME: Need some demo blocks here to show off the function like interp2.m. 195 ## FIXME: Need some demo blocks here to show off the function like interp2.m.
196 196
197 %!test # basic test 197 %!test # basic test
198 %! x = y = z = -1:1; y = y + 2; 198 %! x = y = z = -1:1; y = y + 2;
199 %! f = @(x,y,z) x.^2 - y - z.^2; 199 %! f = @(x,y,z) x.^2 - y - z.^2;
200 %! [xx, yy, zz] = meshgrid (x, y, z); 200 %! [xx, yy, zz] = meshgrid (x, y, z);
253 %! V = zeros (3,3,3); 253 %! V = zeros (3,3,3);
254 %! V(:,:,1) = [1 3 5; 3 5 7; 5 7 9]; 254 %! V(:,:,1) = [1 3 5; 3 5 7; 5 7 9];
255 %! V(:,:,2) = V(:,:,1) + 2; 255 %! V(:,:,2) = V(:,:,1) + 2;
256 %! V(:,:,3) = V(:,:,2) + 2; 256 %! V(:,:,3) = V(:,:,2) + 2;
257 %! tol = 10 * eps; 257 %! tol = 10 * eps;
258 %! x=[-0.1,0,0.1]; y=x; z=x; 258 %! x=[-0.1,0,0.1]; y=x; z=x;
259 %! assert(interp3(X,Y,Z,V,x,y,z,"spline"), [-0.2, 1.0, 2.2]',tol); 259 %! assert(interp3(X,Y,Z,V,x,y,z,"spline"), [-0.2, 1.0, 2.2]',tol);
260 %! assert(interp3(X,Y,Z,V,x,y,z,"linear"), [NA, 1.0, 2.2]',tol); 260 %! assert(interp3(X,Y,Z,V,x,y,z,"linear"), [NA, 1.0, 2.2]',tol);
261 %! assert(interp3(X,Y,Z,V,x,y,z,"spline", 0), [0, 1.0, 2.2]',tol); 261 %! assert(interp3(X,Y,Z,V,x,y,z,"spline", 0), [0, 1.0, 2.2]',tol);
262 %! assert(interp3(X,Y,Z,V,x,y,z,"linear", 0), [0, 1.0, 2.2]',tol); 262 %! assert(interp3(X,Y,Z,V,x,y,z,"linear", 0), [0, 1.0, 2.2]',tol);
263 263
278 %! 278 %!
279 %!assert (interp3 (z), zout, tol) 279 %!assert (interp3 (z), zout, tol)
280 %!assert (interp3 (z, "linear"), zout, tol) 280 %!assert (interp3 (z, "linear"), zout, tol)
281 %!assert (interp3 (z, "spline"), zout, tol) 281 %!assert (interp3 (z, "spline"), zout, tol)
282 282
283 %% Test input validation 283 ## Test input validation
284 %!error interp3 () 284 %!error interp3 ()
285 %!error interp3 ({1}) 285 %!error interp3 ({1})
286 %!error <EXTRAPVAL must be a numeric scalar> interp3 (1,2,3,4,1,2,3,"linear", {1}) 286 %!error <EXTRAPVAL must be a numeric scalar> interp3 (1,2,3,4,1,2,3,"linear", {1})
287 %!error <EXTRAPVAL must be a numeric scalar> interp3 (1,2,3,4,1,2,3,"linear", ones (2,2)) 287 %!error <EXTRAPVAL must be a numeric scalar> interp3 (1,2,3,4,1,2,3,"linear", ones (2,2))
288 %!warning <ignoring unsupported '\*' flag> interp3 (rand (3,3,3), 1, "*linear"); 288 %!warning <ignoring unsupported '\*' flag> interp3 (rand (3,3,3), 1, "*linear");