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

arraynumbersoddsum

The code should contain only one line.

Best Answer

You can use this code:
y = sum(x(rem(x,2)==1));