Cody

Solution 1704566

Submitted on 8 Jan 2019 by Joanne Marsh
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)))

S = 1.7086 0.1398 0.0500 -1.0749 -1.3017

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

S = 0.4015 0.8070 0.3640 -0.8972 -1.2107

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

S = 0.8018 -0.2181 -2.0925 -1.8978 -0.1272 -0.1523 -0.0318 -0.4855 1.3299 -1.0028 -0.1014 -0.8330 3.4215 0.5164 -0.2787 0.9076 -0.0323 -0.2446 0.9398 -0.6044 0.2510 1.5725 0.0252 0.5993 1.3915

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

S(:,:,1) = 0.5915 2.1954 0.2990 0.7919 -0.9149 0.2574 -0.4565 -0.9965 -0.4115 0.4708 -0.1998 0.0478 -0.6810 -0.2879 1.0961 -0.0460 -1.0246 -0.2841 0.6626 -0.3806 0.4918 0.1549 -0.4447 -1.2063 1.0751 S(:,:,2) = -1.7428 -0.9290 0.5508 0.1449 1.3581 -0.5763 -0.1190 -0.6158 -0.1186 0.1154 1.6055 -0.0394 1.6437 1.8814 -0.4041 -0.4487 0.5391 0.1554 0.6680 -0.3444 0.9568 0.0367 1.2739 0.1462 -0.9021 S(:,:,3) = 0.7917 2.1776 -1.1086 -1.2459 0.6473 -0.0633 0.9712 0.1317 1.2356 0.5150 1.8184 -0.7721 0.7226 -1.1104 -0.8142 -1.3796 -0.6305 1.3289 -1.7923 -0.3276 0.5679 -1.2333 0.2972 -1.2347 0.7399 S(:,:,4) = 0.7763 -2.0831 -1.3300 -0.7957 -0.3562 -1.4615 1.6447 -0.1898 -0.0451 1.0080 -3.4318 -1.1407 0.2130 1.6701 1.0010 0.1844 -1.7075 -0.1866 -0.3359 -0.2065 -0.2261 0.2103 0.9368 1.3365 0.4016 S(:,:,5) = 0.2600 -1.9867 -0.3759 -0.3348 0.7586 -0.0469 0.9132 2.2847 -2.1676 -0.5026 2.8039 0.8000 -0.2527 0.4331 -0.6600 -0.4767 0.0498 0.1940 1.1764 -0.1233 0.2699 -1.2248 1.2699 -0.4215 0.2169

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

S = 1.0551