Replace Vector Elements - MATLAB Cody - MATLAB Central

Problem 710. Replace Vector Elements

Difficulty:Rate

Replace all elements in a vector which are equal to or smaller than zero with 0.1.

Example:

 A = [1 2 3 -1 0 2 -3 -80];

Answer:

 B = [1 2 3 0.1 0.1 2 0.1 0.1];

Solution Stats

56.42% Correct | 43.58% Incorrect
Last Solution submitted on Jul 02, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
6

Problem Recent Solvers492

Suggested Problems

More from this Author11

Problem Tags

Community Treasure Hunt

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

Start Hunting!