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

4 visualizaciones (últimos 30 días)
The code should contain only one line.

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by