Cody

Solution 463892

Submitted on 29 Jun 2014 by Clemens Giegerich
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.3197 -1.7598 -0.4530 -0.0517 1.3049

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

ans = 1.8785 2.4274 -1.4128 -0.5744 0.9959

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

ans = -0.6437 -0.3350 -0.1149 0.1845 -0.6441 -0.5911 -0.7129 -0.2989 -0.5485 0.1473 0.4695 0.3999 2.0085 0.6505 -0.3076 0.2453 0.4573 0.8588 0.0982 0.5851 -0.3160 -1.7551 0.9008 -0.1454 -1.2751

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

ans(:,:,1) = -0.6156 -0.8919 -1.3539 0.3244 0.7084 0.6034 0.3394 -0.2458 1.0831 1.0509 -0.5108 -0.5824 0.4765 -0.1626 0.6024 0.3332 1.4768 1.0673 1.0547 -0.4452 -1.3441 1.1595 -1.6233 0.3460 -0.4515 ans(:,:,2) = 1.6614 1.1730 0.6030 -2.5132 0.7578 -0.3946 -0.0427 1.3558 -0.0285 0.4252 -0.5132 -0.4020 0.0034 -0.3986 -0.2551 -0.1631 -1.8501 0.9371 1.1767 1.2935 0.0425 0.3529 0.3847 1.0068 -0.0291 ans(:,:,3) = 1.2212 -0.5320 -0.3061 1.7868 -0.0501 -0.8741 -0.3920 0.1601 0.3895 0.1634 1.0081 -1.8059 0.5607 0.4859 -0.8459 1.2649 0.2547 0.2777 -0.1946 -0.8225 -1.4469 0.5031 1.3931 -0.4670 -0.6687 ans(:,:,4) = -3.0323 -1.6081 3.6731 0.8031 0.7332 -2.0562 0.1847 0.1856 -1.6616 1.7211 -0.1738 1.8031 -0.0200 -0.1838 -0.7168 1.8563 2.1229 -0.2539 -0.3987 0.9153 0.0727 -0.3730 0.6534 -0.9053 0.4570 ans(:,:,5) = -0.7685 0.8140 -0.0518 -0.2441 0.1504 0.1315 -0.2664 -0.5759 -1.4825 0.4093 -0.5115 -0.0348 -1.0638 0.7182 1.1219 -0.0522 -0.6921 1.9442 1.8657 -0.1158 0.1724 0.2951 2.4323 -0.9687 -0.0426

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.8513

Suggested Problems

More from this Author57