Cody

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

Solution 3175656

Submitted on 12 Oct 2020 by Nikolaos Nikolaou
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))

x = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 x = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

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))

x = 3 3 3 4 5 3 3 4 6 x = 3 3 3 4 5 3 3 4 5 y = 3 3 3 4 5 3 3 4 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 x = 30 39 48 7 10 19 28 38 47 7 9 18 27 29 46 7 8 17 26 35 37 7 14 16 25 34 36 45 13 15 24 33 42 44 7 21 23 32 41 43 7 12 22 31 40 49 7 11 20 x = 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 y = 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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!