Wed 22 Feb 2012 07:24:19 PM UTC, original submission:
cat gives the correct vertical concatenation behavior for N-D arrays. For example,
A = cat(1, ones(1, 5, 2), 2*ones(1, 5, 2))
returns
A =
ans(:,:,1) =
1 1 1 1 1
2 2 2 2 2
ans(:,:,2) =
1 1 1 1 1
2 2 2 2 2
However, using a semicolon, which should be equivalent to cat(1, ..) according to the manual and which does work in 2-D, leads to garbage:
A = [ones(1, 5, 2); 2*ones(1, 5, 2)]
A =
ans(:,:,1) =
2.0000e+00 2.0000e+00 2.0000e+00 2.0000e+00 2.0000e+00
2.6744e-316 2.4173e-316 2.4189e-316 2.4072e-316 2.3905e-316
ans(:,:,2) =
2.0000e+00 2.0000e+00 2.0000e+00 2.0000e+00 2.0000e+00
2.4189e-316 2.4190e-316 2.4190e-316 2.4190e-316 2.4190e-316
(The exact garbage returned changes from call to call.)
On the other hand, using the comma for concatenation along the second dimension gives the same results as cat(2, ..), as expected.
|