Cody

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

Solution 2278236

Submitted on 13 May 2020 by Karl Ezra Pilario
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))

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

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

Suggested Problems

Community Treasure Hunt

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

Start Hunting!