Cody

# Problem 43607. Logical array indexing - part 1

Solution 1705893

Submitted on 11 Jan 2019 by HH
• Size: 9
• This is the leading solution.
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 = [3 4 5 6 2 4 5 6 3 6]; n = 4; y_correct = [0 0 5 6 0 0 5 6 0 6]; assert(isequal(find_elements(A,n),y_correct))

[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 find_elements (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
A = [0; 6; 1; 7; 3; 5; 2; 4]; n = 3; y_correct = [0; 6; 0; 7; 0; 5; 0; 4]; assert(isequal(find_elements(A,n),y_correct))

[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 find_elements (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
A = magic(4); n = 8; y_correct = [16 0 0 13; 0 11 10 0; 9 0 0 12; 0 14 15 0]; assert(isequal(find_elements(A,n),y_correct))

[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 find_elements (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]