Cody

Solution 595451

Submitted on 12 Mar 2015 by goc3
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)))

n = 2 ans = -1.0161 0.9156 1.4610 -0.0049 0.4067

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

n = 2 ans = 0.9167 1.1113 -0.1072 1.7540 0.8991

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

n = 2 ans = 1.2246 0.5921 1.6695 -1.3479 -2.6674 -0.4202 1.8775 -1.8971 -1.0651 0.1087 0.1527 2.3444 -0.8430 0.5152 0.9998 -1.2243 0.3580 -0.9814 -0.4259 -2.0892 0.3272 -0.4868 1.5617 -0.7997 -0.1993

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

n = 4 ans(:,:,1) = 0.9049 0.7590 0.0511 -0.1006 -0.4485 0.2761 -0.6154 0.3220 0.5256 1.7821 -0.1588 0.9491 -0.0327 -0.5882 0.6306 0.6372 -1.6007 0.0976 0.4844 0.6216 -0.4281 -0.6617 -0.7037 0.1304 -0.0803 ans(:,:,2) = 0.5160 0.5717 -0.7750 -0.8667 0.6812 -0.6293 0.5296 1.5841 -0.1977 0.7574 -0.8721 0.3086 -0.3049 0.8264 0.0686 -1.4079 0.0425 1.5048 2.1333 0.3677 0.5951 0.1100 1.6228 -0.1621 0.0967 ans(:,:,3) = 0.4901 0.1245 0.0236 0.8484 0.7362 0.9865 -0.7636 -0.9989 0.5818 -0.1440 -0.9488 0.3771 -2.0298 -0.9012 -1.1119 1.9514 2.2317 0.1367 -1.6975 0.6531 0.7349 0.1136 0.0943 0.5081 0.7269 ans(:,:,4) = -0.2336 0.4875 0.1871 -0.3559 -0.5412 -0.2833 0.1440 0.0071 -0.0876 -0.7653 -0.4965 0.3136 0.2963 1.4323 1.4466 0.5831 1.1266 0.7914 -0.8003 1.8511 -0.9449 -1.1647 0.1139 0.9529 1.4610 ans(:,:,5) = 0.5115 -0.5676 0.2005 -0.4091 0.0756 -0.9186 0.4332 -2.4144 -0.2993 -0.8375 0.8441 1.1712 0.4474 0.4573 -0.7486 1.1498 -0.9898 1.2911 1.0966 0.1429 -2.4682 -0.4971 -0.0493 -1.6965 -0.6024

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)))

n = 18 ans = -0.3321