Mercurial > hg > octave-lyh
comparison scripts/plot/ndgrid.m @ 13263:a156263b5509
Add tests for meshgrid and ndgrid.
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Sun, 02 Oct 2011 20:13:33 +0200 |
parents | c792872f8942 |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
13262:37e6f54cca15 | 13263:a156263b5509 |
---|---|
67 | 67 |
68 varargout{i} = repmat (reshape (varargin{i}, r), s); | 68 varargout{i} = repmat (reshape (varargin{i}, r), s); |
69 endfor | 69 endfor |
70 | 70 |
71 endfunction | 71 endfunction |
72 | |
73 %!test | |
74 %! x = 1:2; | |
75 %! y = 1:3; | |
76 %! z = 1:4; | |
77 %! [XX, YY, ZZ] = ndgrid (x, y, z); | |
78 %! assert (size_equal (XX, YY, ZZ)); | |
79 %! assert (ndims (XX), 3); | |
80 %! assert (size (XX), [2, 3, 4]); | |
81 %! assert (XX(1) * YY(1) * ZZ(1), x(1) * y(1) * z(1)); | |
82 %! assert (XX(end) * YY(end) * ZZ(end), x(end) * y(end) * z(end)); | |
83 | |
84 %!test | |
85 %! x = 1:2; | |
86 %! y = 1:3; | |
87 %! [XX1, YY1] = meshgrid (x, y); | |
88 %! [XX2, YY2] = ndgrid (x, y); | |
89 %! assert (size_equal (XX1, YY1)); | |
90 %! assert (size_equal (XX2, YY2)); | |
91 %! assert (ndims (XX1), 2); | |
92 %! assert (size (XX1), [3, 2]); | |
93 %! assert (size (XX2), [2, 3]); | |
94 %! assert (XX2(1) * YY2(1), x(1) * y(1)); | |
95 %! assert (XX2(end) * YY2(end), x(end) * y(end)); | |
96 %! assert (XX1, XX2.'); | |
97 %! assert (YY1, YY2.'); |