Write a single line code to sum all the odd numbers of an array.

1 view (last 30 days)
The code should contain only one line.

Accepted Answer

Abhishek Jain
Abhishek Jain on 4 Oct 2016
You can use this code:
y = sum(x(rem(x,2)==1));

More Answers (0)

Categories

Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!