Problem 824. Set the array elements whose value is 13 to 0
Input A either an array or a vector (which can be empty)
Output B will be the same size as A . All elements of A equal to 13 (if any) must be replaced by zero.
For example:
A = [15 13 3]
output B is:
B= [15 0 3]
The difficulty in this problem is that the following commands FOR , WHILE , FIND and IND2SUB cannot be used.
Solution Stats
Problem Comments
-
3 Comments
this is a good problem
damn man!!! i just tore my head off to solve this then i figured there is a very very simple way to do that
A simple yet good problem. It made me think outside of using if and for loop.
Solution Comments
Show commentsProblem Recent Solvers1399
Suggested Problems
-
Set some matrix elements to zero
587 Solvers
-
Calculate the Hamming distance between two strings
327 Solvers
-
Magic is simple (for beginners)
10353 Solvers
-
Find out missing number from a vector of 9 elements
307 Solvers
-
Create an n-by-n null matrix and fill with ones certain positions
659 Solvers
More from this Author30
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!