Replace odd number in given matrix by zero - MATLAB Cody - MATLAB Central

Problem 2517. Replace odd number in given matrix by zero

Difficulty:Rate

Replace the odd numbers in a given matrix with zero.

Example

 A = [  17    24     1     8    15
        23     5     7    14    16
         4     6    13    20    22
        10    12    19    21     3
        11    18    25     2     9 ]

The answer should be

     [   0    24     0     8     0
         0     0     0    14    16
         4     6     0    20    22
        10    12     0     0     0
         0    18     0     2     0 ]

Solution Stats

53.36% Correct | 46.64% Incorrect
Last Solution submitted on Feb 24, 2025

Problem Comments

Solution Comments

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

Problem Recent Solvers146

Suggested Problems

More from this Author70

Problem Tags

Community Treasure Hunt

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

Start Hunting!