Cody

Solution 113141

Submitted on 16 Jul 2012 by Aurelien Queffurust
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 = 1.4090 1.4172 0.6715 -1.2075 0.7172
2   Pass
%% A = randn(5,5); assert(isequal(arraySlice(A,4,1),A(4,:)))
ans = -1.1471 0.3252 -0.2414 -0.1649 0.0774
3   Pass
%% A = randn(5,5); assert(isequal(arraySlice(A,1,10),A))
ans = -1.1135 -0.2256 1.1006 -1.0616 0.8886 -0.0068 1.1174 1.5442 2.3505 -0.7648 1.5326 -1.0891 0.0859 -0.6156 -1.4023 -0.7697 0.0326 -1.4916 0.7481 -1.4224 0.3714 0.5525 -0.7423 -0.1924 0.4882
4   Pass
%% A = randn(5,5,5,3); assert(isequal(arraySlice(A,3,4),A(:,:,:,3)))
ans(:,:,1) = -2.1321 -1.4286 -2.4969 0.7477 0.6647 1.1454 -0.0209 0.4413 -0.2730 0.0852 -0.6291 -0.5607 -1.3981 1.5763 0.8810 -1.2038 2.1778 -0.2551 -0.4809 0.3232 -0.2539 1.1385 0.1644 0.3275 -0.7841 ans(:,:,2) = -1.8054 0.1136 -0.8608 -0.2841 -0.0942 1.8586 -0.9047 0.7847 -0.0867 0.3362 -0.6045 -0.4677 0.3086 -1.4694 -0.9047 0.1034 -0.1249 -0.2339 0.1922 -0.2883 0.5632 1.4790 -1.0570 -0.8223 0.3501 ans(:,:,3) = -1.8359 0.4286 -0.8759 -1.0257 -0.1178 1.0360 -1.0360 0.3199 -0.9087 0.6992 2.4245 1.8779 -0.5583 -0.2099 0.2696 0.9594 0.9407 -0.3114 -1.6989 0.4943 -0.3158 0.7873 -0.5700 0.6076 -1.4831 ans(:,:,4) = -1.0203 1.2616 -1.4814 -0.3086 -0.0638 -0.4470 0.4754 0.1555 -1.0966 0.6113 0.1097 1.1741 0.8186 -0.4930 0.1093 1.1287 0.1269 -0.2926 -0.1807 1.8140 -0.2900 -0.6568 -0.5408 0.0458 0.3120 ans(:,:,5) = 1.8045 0.5939 1.4702 0.3975 -0.4251 -0.7231 -2.1860 -0.3268 -0.7519 0.5894 0.5265 -1.3270 0.8123 1.5163 -0.0628 -0.2603 -1.4410 0.5455 -0.0326 -2.0220 0.6001 0.4018 -1.0516 1.6360 -0.9821
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.0549