Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 47614

Submitted on 21 Feb 2012 by S L

Correct

43Size
Leading solution size is 26.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
A = randn(5,5);
assert(isequal(arraySlice(A,4,2),A(:,4)))

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

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

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

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