Cody

# Problem 375. N-Dimensional Array Slice

Solution 2954881

Submitted on 16 Sep 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)))

list = 1 2 3 4 5 listnotI = 1 2 3 5 listd = 1 2 listdnotd = 1

Unrecognized function or variable 'listnoti'. Error in arraySlice (line 16) S.subs{d} = listnoti 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,:)))

list = 1 2 3 4 5 listnotI = 1 2 3 5 listd = 1 2 listdnotd = 2

Unrecognized function or variable 'listnoti'. Error in arraySlice (line 16) S.subs{d} = listnoti Error in Test2 (line 2) assert(isequal(arraySlice(A,4,1),A(4,:)))

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

list = 1 listnotI = [] listd = 1 2 listdnotd = 1 2

Unrecognized function or variable 'listnoti'. Error in arraySlice (line 16) S.subs{d} = listnoti 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)))

list = 1 2 3 listnotI = 1 2 listd = 1 2 3 4 listdnotd = 1 2 3

Unrecognized function or variable 'listnoti'. Error in arraySlice (line 16) S.subs{d} = listnoti 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)))

list = 1 2 listnotI = 1 listd = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 listdnotd = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Unrecognized function or variable 'listnoti'. Error in arraySlice (line 16) S.subs{d} = listnoti Error in Test5 (line 2) assert(isequal(arraySlice(A,2,18),A(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,2)))

### Community Treasure Hunt

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

Start Hunting!