Cody

# Problem 42863. Replace values out of an interval with the lower or upper values

Solution 1693237

Submitted on 15 Dec 2018 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
x = ones(1,25); n=[0,2]; y_correct = x; assert(isequal(limit2interval(x,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 limit2interval (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
x= [1 2 3 4 5 1 2 4 6]; n=[3,5]; y_correct= [3 3 3 4 5 3 3 4 5]; assert(isequal(limit2interval(x,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 limit2interval (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
x= magic(7); n=[7,14]; y_correct=ones(7)*14-sparse([4 5 3 2 3 1 2 1 7 6 7 5 6],[1 1 2 3 3 4 4 5 5 6 6 7 7],[7 1 7 7 6 7 5 4 7 7 3 7 2]) assert(isequal(limit2interval(x,n),y_correct))

y_correct = 14 14 14 7 10 14 14 14 14 7 9 14 14 14 14 7 8 14 14 14 14 7 14 14 14 14 14 14 13 14 14 14 14 14 7 14 14 14 14 14 7 12 14 14 14 14 7 11 14 [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 limit2interval (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]