Cody

Solution 1997697

Submitted on 31 Oct 2019 by Pooja Lalan
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 = 0.0682 -1.5147 0.0320 -1.1297 -0.2952

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

S = 0.4173 -0.4572 1.0432 1.5992 -0.3621

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

S = -0.3755 -1.4857 0.1912 -0.3726 -1.3696 0.0380 0.0300 0.2926 1.4681 -0.2645 0.5886 0.3056 -1.3193 -0.3066 -0.0642 -1.4115 -0.1877 -0.5773 0.6106 -2.0099 -1.2517 -0.1124 0.7517 0.1948 -1.2552

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

S(:,:,1) = 0.5055 0.2373 -0.0514 -0.3672 -0.2605 -0.6850 -1.3726 -0.4282 0.8093 -0.3192 0.0987 -0.7530 0.1223 -0.3388 -0.0952 -0.7556 -0.3446 -0.4095 0.5405 -0.4085 -0.3766 -0.1645 0.0865 -1.1664 0.0046 S(:,:,2) = -0.6247 0.1784 0.9761 0.2478 -0.9458 1.2912 0.7672 -1.9664 0.0177 0.0111 -0.1606 1.6991 -0.2700 -0.2475 -0.6326 -0.8515 0.5179 1.4857 1.5168 -0.2965 0.8050 0.6560 1.0870 -1.9339 -2.0928 S(:,:,3) = 0.3530 -0.6404 -1.6372 0.9929 0.2945 1.6803 -0.8010 1.2893 -0.6693 -0.0676 -1.1663 0.9918 -0.0302 -0.9172 -0.0192 0.5035 -1.1228 -1.3937 -0.0301 1.6963 0.6689 -0.3030 -1.3161 0.0798 0.1576 S(:,:,4) = -1.1769 -0.0537 0.1963 -0.9012 0.2671 -0.6548 -0.8615 1.4537 0.9986 -0.2407 -1.2756 1.5388 0.8820 -0.3891 1.1529 0.5301 0.3195 -0.3481 0.0793 -1.6281 -0.7181 -0.1457 -0.3416 -0.5890 -1.6568 S(:,:,5) = 0.3555 0.9351 0.2174 0.8141 0.6021 -0.3526 -0.6322 -1.6526 0.1063 -1.5141 0.9566 -0.4257 1.1400 1.2358 1.1506 0.5648 0.8481 -1.2319 1.4936 0.4416 1.3169 0.2129 0.4528 -0.5697 -0.2406

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 = 0.2046