Replace values out of an interval with the lower or upper values - MATLAB Cody - MATLAB Central

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

Difficulty:Rate

For a vector or matrix X and an interval [n1,n2], the function replace every element of x inferior to n1 by n1, and every element of x superior to n2 by n2.

Example

 x= [1 2 3 4 5 1 2 4 6]
 n=[3,5]
 y_correct= [3 3 3 4 5 3 3 4 5]

Solution Stats

76.4% Correct | 23.6% Incorrect
Last Solution submitted on Jan 02, 2025

Problem Comments

Solution Comments

Show comments
R2025a Pre-release highlights
This topic is for discussing highlights to the current R2025a Pre-release.
14
6

Problem Recent Solvers66

Suggested Problems

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page