Cody

Solution 422373

Submitted on 25 Mar 2014 by J.R.! Menzinger
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% A = randn(5,5); assert(isequal(arraySlice(A,4,2),A(:,4)))

ans = -0.1977 -1.2078 2.9080 0.8252 1.3790

2   Pass
%% A = randn(5,5); assert(isequal(arraySlice(A,4,1),A(4,:)))

ans = -0.8236 -1.3337 -0.2620 -1.1564 -0.0200

3   Pass
%% A = randn(5,5); assert(isequal(arraySlice(A,1,10),A))

ans = -0.7982 -0.2248 2.5260 -0.1765 0.3335 1.0187 -0.5890 1.6555 0.7914 0.3914 -0.1332 -0.2938 0.3075 -1.3320 0.4517 -0.7145 -0.8479 -1.2571 -2.3299 -0.1303 1.3514 -1.1201 -0.8655 -1.4491 0.1837

4   Pass
%% A = randn(5,5,5,3); assert(isequal(arraySlice(A,3,4),A(:,:,:,3)))

ans(:,:,1) = 1.8045 0.5939 1.4702 0.3975 -0.4251 -0.7231 -2.1860 -0.3268 -0.7519 0.5894 0.5265 -1.3270 0.8123 1.5163 -0.0628 -0.2603 -1.4410 0.5455 -0.0326 -2.0220 0.6001 0.4018 -1.0516 1.6360 -0.9821 ans(:,:,2) = 0.6125 -0.9930 0.1992 0.9421 0.1202 -0.0549 0.9750 -1.5210 0.3005 0.5712 -1.1187 -0.6407 -0.7236 -0.3731 0.4128 -0.6264 1.8089 -0.5933 0.8155 -0.9870 0.2495 -1.0799 0.4013 0.7989 0.7596 ans(:,:,3) = -0.6572 0.5954 0.2296 0.0923 0.9105 -0.6039 1.0468 0.4400 1.7298 0.8671 0.1769 -0.1980 -0.6169 -0.6086 -0.0799 -0.3075 0.3277 0.2748 -0.7371 0.8985 -0.1318 -0.2383 0.6011 -1.7499 0.1837 ans(:,:,4) = 0.2908 -1.1667 -0.1685 1.7783 -1.8356 0.1129 -1.8543 -0.2185 1.2231 0.0668 0.4400 -1.1407 0.5413 -1.2833 0.0355 0.1017 -1.0933 0.3893 -2.3290 2.2272 2.7873 -0.4336 0.7512 0.9019 -0.0692 ans(:,:,5) = -0.5073 -1.2226 -0.4189 -0.3451 -1.0431 0.2358 0.3165 -0.1403 1.0128 -0.2701 0.2458 -1.3429 0.8998 0.6293 -0.4381 0.0700 -1.0322 -0.3001 -0.2130 -0.4087 -0.6086 1.3312 1.0294 -0.8657 0.9835

5   Pass
%% A = randn(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2); assert(isequal(arraySlice(A,2,18),A(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,2)))

ans = 1.1437

Suggested Problems

More from this Author57