Cody

# Problem 1896. Index one element in each vector of an array along a given dimension

Solution 1225121

Submitted on 5 Jul 2017 by Chris Cleveland
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
for a = 1:30 ndms = ceil(rand(1) * 5) + 1 sz = 1 + ceil(rand(1, ndms) * 10); A = rand(sz); sz1 = sz(1); sz(1) = 1; I = ceil(rand(sz) * sz1); B = reshape(A(I(:)+(0:sz1:numel(A)-1)'), size(I)); p = randperm(ndms); A = permute(A, p); I = permute(I, p); B = permute(B, p); assert(isequal(dimsel(A, I), B)); end

ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 4 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 3 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 3 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 4 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 3 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 4 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 5 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 3 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 5 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 6 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 5 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 5 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 5 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 6 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 3 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 6 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 4 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 3 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 5 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 6 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 5 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 3 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)] ndms = 2 [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In dimsel (line 2) In ScoringEngineTestPoint1 (line 13) In solutionTest (line 3)]