Cody

Problem 375. N-Dimensional Array Slice

Solution 2803294

Submitted on 6 Aug 2020
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   Fail
A = randn(5,5); assert(isequal(arraySlice(A,4,2),A(:,4)))

Index exceeds the number of array elements (1). Error in arraySlice>rec (line 7) y = a(I) Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice (line 2) S = rec(A, d, I, 1); Error in Test1 (line 2) assert(isequal(arraySlice(A,4,2),A(:,4)))

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

y = 0.1535

Assertion failed.

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

y = -0.0254

Output argument "y" (and maybe others) not assigned during call to "arraySlice>rec". Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice (line 2) S = rec(A, d, I, 1); Error in Test3 (line 2) assert(isequal(arraySlice(A,1,10),A))

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

Index exceeds the number of array elements (1). Error in arraySlice>rec (line 7) y = a(I) Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice (line 2) S = rec(A, d, I, 1); Error in Test4 (line 2) assert(isequal(arraySlice(A,3,4),A(:,:,:,3)))

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

Index exceeds the number of array elements (1). Error in arraySlice>rec (line 7) y = a(I) Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice>rec (line 12) a(1) = rec(a(1), d, I, ct + 1); Error in arraySlice (line 2) S = rec(A, d, I, 1); Error in Test5 (line 2) assert(isequal(arraySlice(A,2,18),A(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,2)))

Suggested Problems

More from this Author56

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!