Cody

Solution 1855098

Submitted on 21 Jun 2019 by Daniel Yago
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.0008 0.4643 0.4363 2.1753 -0.1405

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

ans = -0.1959 0.5559 -0.6832 2.2448 -1.9624

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

ans = -0.9150 -0.7256 0.2511 1.4485 -0.2540 -0.1538 1.4917 -1.2911 -0.3774 -0.3116 2.1158 0.7167 2.4147 0.8747 -1.5554 0.4526 0.3107 0.1270 0.3660 -0.0447 -0.5412 -0.0416 -0.3947 -0.7561 0.5423

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

ans(:,:,1) = 0.4384 -0.3845 -1.5615 0.5657 0.3822 1.5434 0.3966 -0.5485 0.7236 3.5477 0.5415 -0.2913 0.0388 0.5161 0.3857 -0.1474 -2.3720 -0.1967 -0.5646 1.3455 -2.1866 -0.1163 -0.1130 -1.8077 0.1506 ans(:,:,2) = -0.1710 -0.6020 -1.1117 -2.1177 1.0319 0.3584 -1.2528 -0.6502 -0.3466 0.5759 1.9444 0.6643 -0.4804 -2.2334 -1.0114 0.0650 -1.0156 -1.2533 0.6785 -0.1422 1.4781 -0.7370 0.6089 0.3128 0.3284 ans(:,:,3) = -1.3702 -0.7119 -0.2106 -1.8945 1.2790 -0.6027 1.7287 0.3547 0.0371 1.8932 0.5737 -1.7368 -0.7562 -1.0002 -0.9153 2.8380 0.4179 2.2178 0.1234 -1.6116 1.2400 0.4627 -1.0040 0.5123 -0.5746 ans(:,:,4) = -1.2033 -0.6377 -1.5062 -0.0196 -0.6685 -0.1113 -0.1903 -0.9294 -1.1806 -1.1657 1.6047 0.5304 -0.3412 0.3623 0.4253 1.8235 0.5085 1.1157 -0.2583 0.3753 1.1085 -0.0455 1.2432 -0.8541 1.7137 ans(:,:,5) = -0.2669 -0.7188 1.7346 -0.7097 1.3862 0.8224 -0.3029 0.7111 -1.1856 -0.0755 0.2926 0.6796 1.1495 -0.2292 1.2175 -1.5211 -1.3918 -0.4442 -0.9874 0.2104 0.6713 1.7250 -1.8005 0.2756 0.2752

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